Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions 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). ]
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY