Math, Large Small, MultOf#

advertisement
CIST 1400, Introduction to Computer Programming
Programming Assignment
Program 5 ::
20 points
:: Due
See Blackboard
@ 11:59 PM
This problem asks you to read in six integer numbers from the user and then determine and
print what the largest and smallest of those values are. When you perform your output, display
it on a line by itself and print out the smallest value, followed immediately by a colon, followed
immediately by the largest value. Print the final output only once.
Here is an incomplete bit of code that can use to get you started:
int value, smallest, largest;
Scanner get = new Scanner ( System.in );
System.out.print( "Please enter first integer: " );
value = get.nextInt();
// Start processing and reading more numbers to determine largest
// and smallest.
// Don't use logical operators (&&,||) or the if/else statement;
// we haven't covered them.
// Don't forget to output the final results only once!
Goals





Edit, compile and run a simple and fairly straightforward program with a small snippet of
code to use to get started. You do not need to use this starter code if you don't want to.
Create integer variables and use them appropriately in the program.
Input values from the user and store those values into variables.
Find the largest and smallest of a set of integer numbers.
Use only the if selection statement to make conditional decisions.
Class and File Naming

Name your class NetID_SmallestLargest and source file
NetID_SmallestLargest.java, using your UNO NetID. For example, for Loki
account jsmith, he or she would create a class jsmith_SmallestLargest.
Submitting Your File
See the document in Blackboard Course Materials for how to submit your assignment.
Page 1 of 2
CIST 1400, Introduction to Computer Programming
Programming Assignment
Grading Notes






Remember that programs must be created in Loki using vim.
Remember that your program requires a complete, digitally signed Honor Pledge to be
graded.
Only use material through lecture 5. By this point, we’ve covered if, if/else and
logical operators. You may not need to use all of those structures or operators, and in
fact your code may be shorter if you focus on just the if statement.
Name your class according to the “Class and File Name” section above.
Only output the largest and smallest values once in your program.
Make sure your output follows the format outlined above and according to the example
below here. A portion of your grade is for following this format exactly.
Points to Think About




Does your program handle negative numbers in the input sets?
For six distinct input values, there are 720 possible combinations of those numbers. To
completely test your program, you would want to test all 720 possibilities. Since you
probably won't test all of those possibilities, you should at least test about 15 or 20
possible combinations with the largest and smallest values in each of the positions (i.e.,
1 2 3 4 5 6 and then 2 1 3 4 5 6, etc).
You should also test if the same value occurs more than once in the input (i.e., 2 3 -1
6 -1).
What if all of the numbers are the same (i.e., 62 62 62 62 62)?
Sample Program Run (user input is
underlined)
Sample Program Run (user input is
underlined)
Please
Please
Please
Please
Please
Please
Please
Please
Please
Please
Please
Please
enter
enter
enter
enter
enter
enter
first number: 123487
second number: -18822
third number: 12347
fourth number: -314
fifth number: 432123
sixth number: 432121
-18822:432123
62:62
Page 2 of 2
enter
enter
enter
enter
enter
enter
first number: 62
second number: 62
third number: 62
fourth number: 62
fifth number: 62
sixth number: 62
Download