Getting Started: It's time for new partners! Your lab leaders will tell you who to work with for this second month of lab sessions. Do the posted Blackboard poll (week 5 quiz). Your lab leaders will review the answers before you get started on this week's exercise.
We will use the iterative development approach again, with all coding phases this week. Try to finish all parts, but you do NOT have to stay beyond the scheduled 3 hours of lab! Remember to switch roles after each phase is completed. As was the case last week, at each step you should make sure that your code not only compiles, but is also checkstyle compliant, using our configuration file! Have a lab leader admire your work between stages.
A menu-driven program is one in which the user is presented with a list of choices, and must continue to pick a choice until they quit. For this program, each choice will correspond to an operation. Then the program will perform the operation, including getting any additional input that is needed. Here is a sample run to show you how each transaction is supposed to work. In the actual program, the user can choose the operations in any order, as many different times as s/he wants.
Please choose an operation: 0) time 1) letters 2) rectangle 3) graph 4) quit choice -> 0 enter time of day in HH:MM:SS format: 13:30:05 48605 seconds since midnight Please choose an operation: 0) time 1) letters 2) rectangle 3) graph 4) quit choice -> 1 enter two letters: M b B C D E F G H I J K L M Please choose an operation: 0) time 1) letters 2) rectangle 3) graph 4) quit choice -> 2 enter height, width & display character: 3 8 $ $$$$$$$$ $$$$$$$$ $$$$$$$$ Please choose an operation: 0) time 1) letters 2) rectangle 3) graph 4) quit choice -> 3 enter all the numbers to process on one line: 23 14 4 20 8 *********************** ************** **** ******************** ******** Please choose an operation: 0) time 1) letters 2) rectangle 3) graph 4) quit choice -> 0 enter time of day in HH:MM:SS format: 04:12:00 15120 seconds since midnight Please choose an operation: 0) time 1) letters 2) rectangle 3) graph 4) quit choice -> 4 BYE!
Step 1) Write a program which repeatedly displays the transaction menu and reads an option from the user until they quit. Do not write the code to process any transactions yet, except to output one word indicating which operation was chosen.
Step 2) Add to the program so that it correctly processes the first operation - calculating the number of seconds. You can assume that the input always has exactly two digits for each part (hours, minutes, seconds). But if you want an extra challenge, try not making this assumption. You'll need to use some String operations and do some converting between Strings and number types to get the right results.
Step 3) Add to the program so that it correctly processes the second operation - the letters transaction. First get it to work if the characters are input in the correct order, in upper case. Then add processing to handle the cases where they are not both given in upper case, or are not in the correct order.
Step 4) Add processing for the third operation - the rectangle display. You'll need to use nested loops to solve this part!
Step 5) Add processing for the last transaction type - bar graph. Reading the input for this part can be challenging. You might want to use nextLine to read all the values at once. Then you can initialize a second Scanner object with the input string, and use nextInt on the second Scanner to get one number at a time. Put this in a loop to get all the numbers on the line. First get this operation working so that it just prints the numbers, one per line. Then change it so that it prints a string of stars instead, where the number of stars corresponds to the value.
Extra) For an extra challenge, update the third operation so that it displays the outline of the rectangle, instead of a solid block of characters.
Step 6) CLEAN-UP: Zip all the files together from today's lab and email to both students. Then each student must submit their work on Blackboard for the week, noting their partner's name and JHED login in the submission textbox. You must then delete your files off the lab computer and logout before leaving! Failure to do so constitutes an ethics violation.