Due by the end of Tuesday, 19 January 2021
Revise the program so that it prints multiple rectangles -- prompting for more heights and widths until a negative height is entered. Use good sentinel-loop design. In particular, that means no if control of any sort.
It's OK to start if the user has to enter a width after the negative height, but if you think about it, you should be able to figure out how to write it so that the user can just press enter after the negative height. And you can do it without using an if control. All you have to do is place the while control in the right place!
Create a simple program named Answers.java that implements the following pseudo-code:
Use good design. In particular, use if-else-if controls as appropriate.
Remember that there are String methods for checking what a String startsWith or endsWith.
roll = 1 + (int)(6 * Math.random());It rolls the die 600 times, counting how many of each number were rolled. (Use an appropriate kind of loop.)
Remember to name the numbers 6 and 600 in this program.
Use an array to hold the six counters you need.
Hint:
- Let counter[roll-1] keep track of how many times roll was rolled.
- Think about the way we add one to a variable. So, how do you add one to counter[roll-1]?
- Does the way we add one to counter[roll-1] change depending on what value roll has?
After the rolls have all been counted, print out the counts in a little table. For example:
Roll Count 1 100 2 102 3 98 4 108 5 103 6 89
Submit this/these files:
You will be graded on the following: