
None of the first 3 or 4 exercises should take your team more than 10min each. They are
all small variations on what we've done before. If you can't understand and get each of them going in
a relatively short period of time it means either you are a very sloooooooooow typist or you need to be
spending more time with the material of this class -- in particular writing, compiling, & running programs!
-
Write a program that correctly implements both 1 & 2 of the quiz in the same program.
Make your output to the terminal as clear, neat, and readable as possible.
-
Read a command line argument integer. If value is evenly divisible by three,
report the result of two "coin flips" and program ends.
Each "coin flip" should be implemented using Math.random() If the value is less than 0.5 report 'tails'
otherwise report 'heads'.
-
Continue working the same program but add some more tests. If the command line argument is evenly divisible by five,
use the absolute value of the argument as the radius of a circle and calculate the perimeter.
-
If the value is not evenly divisible by 3 nor 5,
use the value as the diameter of a circle and calculate the area.
-
Start a new program now.
Generate three random integers between 0 and 255 inclusive. Later we can use such values to generate colors.
For now, let's just use them to practice more with if-statements.
The first number will the be amount of red.
The second number will the be amount of green.
The third number will the be amount of blue.
Report which of the three is the largest by first printing all three numbers and then printing one of the
following three words -- red, green, blue. It's unlikely that you'll get repeat values, but if you do, I'll
leave it to your descretion how to handle it. -
Okay, exercises 2,3,4 should all be in the same program.
Take a break from programming and draw a flow chart for this
program now on a blank piece of paper. Make sure both of your names
are on it and submit to me before you leave. BOTH OF YOU SHOULD WORK ON THIS TOGETHER. NO ONE SHOULD BE typing until I have your submission.
-
Generate two random integers with a value randomly selected from 1,2,3,4,5,6.
Report the sum of the two numbers.
Report which of the two is largest.
When neither value is larger, report a "double" value and what the value is
When the double value is 1, report "snake eyes"
When the double value is 6, report "box cars" -
Start a new program now.
Generate three random integers with a value randomly selected from 1,2,3,4,5,6. If we consider these the
faces on three dice, then we can describe the roll of them in the following ways.
First list the numerical value of each face.
When all the numbers are different, report a "nothing interesting"
When two of the numbers are the same, report a "double" and be sure to tell the user a double of what value
unless it's a 1 when you should report 'snake eyes' or a 6 when you should report 'box cars'.
When three of the numbers are the same, report a "triple" and be sure to tell the user a triple of what value. -
Congratulations!
Read the next section in the book on while loops.
Write a program that will generate 10 random numbers between -3 and 2
inclusive. Printing them as you go.
-
Now instead of printing the random numbers instead generate 1000 of them
and make a counter for each of them.
Your program should report out how many -3's were generated
how many -2's
how many -1's
how many 0's
how many 1's
how many 2's
Please do this one per line so it's not confusing what I'm looking at.