Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

IBM Db2 11 1 Certification Guide Explore Techniques To Master Database Programming And Administration Tasks In IBM Db2

Authors: Mohankumar Saraswatipura ,Robert Collins

1st Edition

1788626915, 978-1788626910

More Books

Students also viewed these Databases questions