1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Zolol [24]
2 years ago
9

Remove gray from RGB Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers repres

ent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray). Given values for red, green, and blue, remove the gray part.

Computers and Technology
1 answer:
sergejj [24]2 years ago
5 0

Answer:  

Here is the C++ program:  

#include <iostream>   //to use input output functions    

using namespace std;   //to identify objects cin cout    

int main() {   //start of main method    

int red,green,blue,smallest;   //declare variables to store integer values of red,green, blue and to store the smallest value    

cout<<"Enter value for red: ";  //prompts user to enter value for red    

cin>>red;  //reads value for red from user    

cout<<"Enter value for green: ";  //prompts user to enter value for green  

cin>>green; //reads value for green from user    

cout<<"Enter value for blue: "; //prompts user to enter value for blue    

cin>>blue;   //reads value for blue from user    

//computes the smallest value  

if(red<green && red<blue) //if red value is less than green and blue values    

smallest=red;   //red is the smallest so assign value of red to smallest    

else if(green<blue)   //if green value is less than blue value    

smallest=green; //green is the smallest so assign value of green to smallest  

else //this means blue is the smallest    

smallest=blue;  //assign value of blue to smallest    

//removes gray part by subtracting smallest from rgb  

red=red-smallest; //subtract smallest from red    

green=green-smallest; //subtract smallest from green    

blue=blue-smallest; //subtract smallest from blue    

cout<<"red after removing gray part: "<<red<<endl;  //displays amount of red after removing gray    

cout<<"green after removing gray part: "<<green<<endl; //displays amount of green after removing gray  

cout<<"blue after removing gray part: "<<blue<<endl;  } //displays amount of blue after removing gray  

Explanation:  

I will explain the program using an example.    

Lets say user enter 130 as value for red, 50 for green and 130 for blue. So  

red = 130    

green = 50

blue = 130  

First if condition if(red<green && red<blue)   checks if value of red is less than green and blue. Since red=130 so this condition evaluate to false and the program moves to the else if part else if(green<blue) which checks if green is less than blue. This condition evaluates to true as green=50 and blue = 130 so green is less than blue. Hence the body of this else if executes which has the statement: smallest=green;  so the smallest it set to green value.    

smallest = 50    

Now the statement: red=red-smallest; becomes:    

red = 130 - 50    

red = 80    

the statement: green=green-smallest;  becomes:    

green = 50 - 50    

green = 0    

the statement: blue=blue-smallest; becomes:    

blue = 130 - 50    

blue = 80    

So the output of the entire program is:    

red after removing gray part: 80                                                                                                 green after removing gray part: 0                                                                                                blue after removing gray part: 80    

The screenshot of the program along with its output is attached.

You might be interested in
Suppose that a disk drive has 5,000 cylinders, numbered 0 to 4,999. The drive is currently serving a request at cylinder 2,150,
Zina [86]

Answer:

The queue pending requests of FIFO order is ;

86, 1470, 1774, 948, 1509, 1022, 1750, 130.

Explanation:

The FCFS schedule is 143, 86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130.

Total seek distance is 7081.

The SSTF schedule is 143, 130, 86, 913, 948, 1022, 1470, 1509, 1750, 1774.

Total seek distance is 1745.

The LOOK schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 130, 86.

Total seek distance is 3319.

The SCAN schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 4999, 130, 86.

Total seek distance is 9769.

7 0
3 years ago
Explain vividly any operating system of your choice stating at least 3 distinguishing features of each version.
rosijanka [135]

Answer:

microsoft windows, macOS, and linux

Explanation:

if you need help let me know

7 0
3 years ago
Read 2 more answers
Given: int[][] values = new int[4][5] Using the statement above, write a nested loop to set values as follows: (3 pts) [0] [1] [
marshall27 [118]

Answer:

The question is a bit unclear. Are you asking how to add these values in this 2D array?

Explanation:

8 0
3 years ago
Windows OS and Mac OS are examples of which type of operating system?
german
Windows OS and Mac OS are examples of single user, multi tasking Operating Systems.
5 0
3 years ago
Read 2 more answers
How can I convert a string to a int? in Java
Deffense [45]

Answer:

int

Explanation:

5 0
2 years ago
Other questions:
  • Driving while wearing headphones or earphones
    12·2 answers
  • A network of Bennetton retail sales agents select the Bennetton designs that they feel will appeal to Bennetton retail customers
    10·2 answers
  • Which of the following is LEAST needed when programming a computer?
    7·1 answer
  • Is a component that provides a button control in a gui application or applet?
    15·1 answer
  • How can people make sure they are using credit cards responsibly
    14·2 answers
  • Complete the following statement: Sustainability is: Choose all that apply.This task contains the radio buttons and checkboxes f
    10·1 answer
  • When targeting customers of the consumer population at market a product, what type of segmentation information would be most hel
    12·2 answers
  • Select the correct answer.
    10·1 answer
  • Applications of the e-government​
    9·2 answers
  • If an internet document identifies its author but says nothing about her or his qualifications, your textbook recommends that yo
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!