COS 126 Conditionals and Loops |
Programming Assignment Due: 11:55pm |
The goal of this assignment is to write five short Java programs to gain practice writing expressions, loops, and conditionals.
Hint. Math.min(x, y) returns the minimum of x and y.
If all three red, green, and blue values are 0, the resulting color is black (0 0 0 1).% java RGBtoCMYK 75 0 130 // indigo cyan = 0.4230769230769229 magenta = 1.0 yellow = 0.0 black = 0.4901960784313726
% java Distinct 876 5309 5309 There are 2 distinct values % java Distinct 17 17 17 There is 1 distinct value
% java Average 5 0.5920401639695192
% java Checkerboard 4 * * * * * * * * * * * * * * * *
Hint: consider using (i % 10) and (i % 100) to determine when to use "st", "nd", "rd", or "th" for printing the ith Hello.% java Ordinals 22 1st Hello 2nd Hello 3rd Hello 4th Hello 5th Hello ... 10th Hello 11th Hello 12th Hello 13th Hello ... 20th Hello 21st Hello 22nd Hello