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
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
I want solution with steps
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 MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
Step by stepSolved in 3 steps with 1 images
Knowledge Booster
Background pattern image
Similar questions
- Please explain your answer for both questions. For the first part n is greater than or equal to zeroarrow_forwardUsing MATLAB : Please explain the process of how you constructed your code and provide screenshots of the output, pictures and grapharrow_forwardDemonstrate that the following issue falls within the NP class: A set S of integers and an integer number t are provided to us. Does a subset of S such that the product of its components equals t? Note: Problem with Data Structures and Algorithmsarrow_forward
Recommended textbooks for you
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
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