Lab 3: due Sept 16

advertisement
Part I
Write an application that reads 5 integers and determines and prints the largest and
smallest integers in the group. You will need to read in all 5 numbers from the user.
Sample output (blue = your program, black = user input)
Please enter an integer: 3
Please enter an integer: 2
Please enter an integer: 1
Please enter an integer: 4
Please enter an integer: 5
The smallest number is 1.
The largest number is 5.
Hint 1: You will need to make decisions within your program (i.e. utilize if statements as
introduced in class).
Hint 2: By utilizing the logical "And" in java, you can join together multiple expressions. In
Java you can do this using the && operator. For example, if I wanted to check to see if
x<y and x<z I could use the following:
if (x < y && x < z)
Part II
Write an application that reads an integer and determines and prints whether or not it is
odd or even. [Hint: Use the remainder operator. An even number is a multiple of 2. Any
multiple of 2 leaves a remainder of 0 when divided by 2.]
Submit both files below to the Lab 3 Drop Box.
Download