question archive In many languages (including Java), you can form a color by specifying certain amounts of red, green, and blue, with each color's amount ranging from 0% to 100%
Subject:Computer SciencePrice:5.87 Bought7
In many languages (including Java), you can form a color by specifying certain amounts of red, green, and blue, with each color's amount ranging from 0% to 100%. For example, to specify purple, you could use this code
rgb(100%, 60%, 100%)
The rgb stands for red, green, and blue. With 100% for red and blue, the resulting color is purple. In the following Rgb and RgbDriver class skeletons, replace the <insert...> lines with appropriate code such that the program operates properly. More specifically:
rgb(100%, 60%, 100%)
public class Rgb { private int red; private int green; private int blue; <insert setRed method definition here> public Rgb setGreen(int green) { this.green = green; return this; } // end setGreen public Rgb setBlue(int blue) { this.blue = blue; return this; } // end setBlue public void display() { System.out.printf("rgb(%d%%, %d%%, %d%%)n", this.red, this.green, this.blue); } // end display } // end Rgb class public class RgbDriver { public static void main(String[] args) { Rgb rgb = new Rgb(); <insert chained method calls here> } } // end RgbDriver class
Purchased 7 times