Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

# This problem asks you to construct a C++ program to work with color. First have the user input some values. You may assume the value input are always...

This problem asks you to construct a C++ program to work with color. First have the user input some values. You may assume the value input are always integers. To begin this input, have the user input a tolerance. Validate that tolerance: if it is negative ask a user to input a nonnegative tolerance. Do repeatedly until they enter a nonnegative number. Then ask the user to input red, green, and blue components. Each should be an integer between 0 and 255, inclusive. Validate these: if any is outside the range, have the user input three new components. Do these repeatedly until the user enters three valid components.

Once the user has input all valid values, then check if the color is a "near gray," i.e., all the components are within (i.e., less than or equal to) the tolerance of each other, and output a message telling if they are or are not. For example, if the tolerance is 5 and the color is (199, 201, 204), then the components are within 5 of each other. But if the tolerance is 3 and the components are (101, 99, 103), then the components are not since the green and blue components differ by 4.

If the components are within the tolerance of each other, then your program should also identify which component or components have the largest value, and then output a message identifying that component or components. (If the components are not within tolerance, your program should not do that part.) For example, for the color (28, 100, 97) the largest component is green. For the color (0, 100, 100), the largest are green and blue. Note there are a number of possibilities-----your program needs to be able to handle all the possible cases.

Here are four examples of input and output that show the desired program behavior as well as the input and output format and language. As usual, user input is underlined. Also, make sure you follow this output carefully. For example, notice that the language changes slightly when there is a single largest component versus when there are two or three.

First example:

Input tolerance: 2

Input red, green, and blue components: 255 255 255

The color is a near gray. All components are equal.

Second example:

Input tolerance: 0

Input red, green, and blue components: 100 110 100

The color is not a near gray.

Third example:

Input tolerance: -1

Tolerance must be nonnegative.

Input tolerance: 4

Input red, green, and blue components: 99 103 103

The color is a near gray. The green and blue components are largest.

Fourth example:

Input tolerance: -2

Tolerance must be nonnegative.

Input tolerance: -1

Tolerance must be nonnegative.

Input tolerance: 5

Input red, green, and blue components: 0 0 257

All components must be between 0 and 255, inclusive.

Input red, green, and blue components: 99 100 104

The color is a near gray. The blue component is largest.