Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. For each of the following Java methods, state whether or not it meets the definition of a function with domain and codomain Color. If
4. For each of the following Java methods, state whether or not it meets the definition of a function with domain and codomain Color. If not, state the reason why. a. /** * Returns a new Color that is the negative of the given Color public static Color negative (Color c) { return new Color(255 - C.red, 255 - c.green, 255 - c.blue) * Returns a new Color that grayscales' the given Color by averaging its rgb values public static Color grayscale(color c) { int average = (c.red + c.green + c.blue) / 3; return new Color (average, average, average); * Returns a new Color with the same green and blue values * as the given color, but with a red value entered by the user public static Color setRed(Color c) { int newRed; // read in a value from the user to use as the new red value try (Scanner in = new Scanner(System.in)) { System.out.println("Enter a new red value: "); newRed = in.nextInt(); return new Color (newRed, c.green, c.blue)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started