Write a Java class called "Colors.java" that generates two random colors, then it applies a mathematical scaling formula to the randomly generated colors. To declare Colors class, you need to declare the following three methods plus the main method: 1. public static int randomColor ()(-) Write a public static method called randomColor that generates and returns a random primary color code based on the codes shown in the table below. (Hint: you must use an object from SecureRandom class). Primary Color Title Primary Color Code Red 153 Yellow 255 Blue 357 Orange 459 Purple 561 Green 663 2. public static void printColorName (int color) {-} Write a public static method callcd printColorName that receives the color code and prints the color name. (Hint: the color names are shown in the table above with their codes). 3. public static int scaleColor (int X, int Color) {- } Write a public static method called scaleColor which calculates and returns the color code after scaling it by a parameter X (where X is an integer input from the user from 1 to 10 only). For scaling, use the scaling formula below: VCode X scaleColor (X, Code) = 10 (Hint: you must use Math.pow and Math.sqrt from Math class, and X should be read in the main method not inside this method). In the main method of your Colors class, do the following using the methods defined above: 1. First, randomly generate two colors using the static method randomColor (and make sure the generated color codes are NOT the same), then print their color codes in the main method. 2. Next, print the color name by calling printColorName for each generated color. 3. Finally, scale your colors with the value of X (where X value is a user input from 1 to 10) using scaleColor method, and print cach scaled color code after scaling. (Hint. you must apply user validation on X to be from 1 to 10 only).

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
I want solution with steps
Write a Java class called "Colors.java" that generates two random colors, then it applies a mathematical scaling
formula to the randomly generated colors.
To declare Colors class, you need to declare the following three methods plus the main method:
1. public static int randomColor (){-)
Write a public static method called randomColor that generates and returns a random primary color code
based on the codes shown in the table below. (Hint: you must use an object from SecureRandom class).
Primary Color Title
Primary Color Code
Red
153
Yellow
255
Blue
357
Orange
Purple
459
561
Green
663
lic static void printColorName (int color) {
Write a public static method called printColorName that receives the color code and prints the color
2.
name. (Hint: the color names are shown in the table above with their codes).
3. public static int scaleColor (int X, int Color) {- }
Write a public static method called scaleColor which calculates and returns the color code after scaling it
by a parameter X (where X is an integer input from the user from 1 to 10 only). For scaling, use the scaling
formula below:
VCode X
scaleColor(X, Code)
10
(Hint: you must use Math.pow and Math.sqrt from Math class, and X should be read in the main
method not inside this method).
In the main method of your Colors class, do the following using the methods defined above:
1. First, randomly generate two colors using the static method randomColor (and make sure the generated
color codes are NOT the same), then print their color codes in the main method.
2. Next, print the color name by calling printColorName for each generated color.
3. Finally, scale your colors with the value ofX (where X value is a user input from 1 to 10) using
scaleColor method, and print cach scaled color code after scaling. (Hint. you must apply user validation
on X to be from I to 10 only).
Transcribed Image Text:Write a Java class called "Colors.java" that generates two random colors, then it applies a mathematical scaling formula to the randomly generated colors. To declare Colors class, you need to declare the following three methods plus the main method: 1. public static int randomColor (){-) Write a public static method called randomColor that generates and returns a random primary color code based on the codes shown in the table below. (Hint: you must use an object from SecureRandom class). Primary Color Title Primary Color Code Red 153 Yellow 255 Blue 357 Orange Purple 459 561 Green 663 lic static void printColorName (int color) { Write a public static method called printColorName that receives the color code and prints the color 2. name. (Hint: the color names are shown in the table above with their codes). 3. public static int scaleColor (int X, int Color) {- } Write a public static method called scaleColor which calculates and returns the color code after scaling it by a parameter X (where X is an integer input from the user from 1 to 10 only). For scaling, use the scaling formula below: VCode X scaleColor(X, Code) 10 (Hint: you must use Math.pow and Math.sqrt from Math class, and X should be read in the main method not inside this method). In the main method of your Colors class, do the following using the methods defined above: 1. First, randomly generate two colors using the static method randomColor (and make sure the generated color codes are NOT the same), then print their color codes in the main method. 2. Next, print the color name by calling printColorName for each generated color. 3. Finally, scale your colors with the value ofX (where X value is a user input from 1 to 10) using scaleColor method, and print cach scaled color code after scaling. (Hint. you must apply user validation on X to be from I to 10 only).
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY