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
Svetllana [295]
3 years ago
5

Create vector of Color variables

Computers and Technology
1 answer:
Law Incorporation [45]3 years ago
8 0

Answer:

See explaination

Explanation:

balloon.h

#ifndef BALLOON_H

#define BALLOON_H

enum Color {red, orange, yellow, green, blue, indigo, violet};

#endif

main.cpp

#include <iostream>

#include <string>

#include <vector>

#include "balloon.h"

using namespace std;

int main( )

{

vector<Color> colors;

Color color;

string input;

while(true){

cout<<"What color do you want to add? ";

cin>>input;

if(input=="end"){

break;

}else if(input=="red"){

color = red;

colors.push_back(color);

}else if(input=="orange"){

color = orange;

colors.push_back(color);

}else if(input=="yellow"){

color = yellow;

colors.push_back(color);

}else if(input=="green"){

color = green;

colors.push_back(color);

}else if(input=="blue"){

color = blue;

colors.push_back(color);

}else if(input=="indigo"){

color = indigo;

colors.push_back(color);

}else if(input=="violet"){

color = violet;

colors.push_back(color);

}

}

for(int i=0;i<colors.size();i++){

cout<<colors[i]<<endl;

}

return 0;

}

You might be interested in
Which of the following is NOT areserved word in Java?intpublicstaticnum
Rama09 [41]

Answer:

num

Explanation:

In java reserved words are also known as keywords, keywords are reserve words for a language that can't be used as an identifier(name of a class, name of a variable, name of an array etc.) int, public static, are reserve words.

In given question num is not a reserved word.

6 0
2 years ago
Java code?????
12345 [234]

Answer:

Explanation:

Here is the code for you:

import java.io.*;

import java.util.*;

class GirlScoutCookies

{

public static void main(String[] args)

{

int [] BoxesCategory = new int[5];

Scanner sc = new Scanner(System.in);

System.out.print("Total number of girls in the troop: ");

int numOfGirlScouts = sc.nextInt();

for(int i = 0; i < numOfGirlScouts; i++)

{

System.out.print("Boxes of cookies for girl #"+(i+1)+": ");

int boxes = sc.nextInt();

if(boxes >= 0 && boxes <= 10)

BoxesCategory[0]++;

else if(boxes >= 11 && boxes <= 20)

BoxesCategory[1]++;

else if(boxes >= 21 && boxes <= 30)

BoxesCategory[2]++;

else if(boxes >= 31 && boxes <= 40)

BoxesCategory[3]++;

else if(boxes > 40)

BoxesCategory[4]++;

}

System.out.println("TOTAL BOXES\tNUMBER OF GIRL SCOUTS");

System.out.println(" 0 to 10\t"+BoxesCategory[0]);

System.out.println("11 to 20\t"+BoxesCategory[1]);

System.out.println("21 to 30\t"+BoxesCategory[2]);

System.out.println("31 to 40\t"+BoxesCategory[3]);

System.out.println("41 or more\t"+BoxesCategory[4]);

}

}

And the sample output is:

5 0
3 years ago
Which function would you use to make sure all names are prepared for a mailing label? TODAY UPPER PROPER LOWER
Aleonysh [2.5K]

Answer:

Proper.

Explanation:

5 0
2 years ago
For questions 3-6, consider the following two-dimensional array:
elena-s [515]

Answer:

5= Fabric

6=bandana

Explanation:

8 0
3 years ago
Read 2 more answers
Links to the four default folders can be found on the left side of the file explorer window under the _________ heading:
dimulka [17.4K]

Answer:

Libraries

Explanation:

Document itself is a folder and is not a heading by the way.

Local simply means on the machine you are working and does not have default folders.

Desktop is  name of screen which is used as a gateway for using windows.

So, they cannot be correct answers.

4 0
3 years ago
Read 2 more answers
Other questions:
  • For C++ (please make sure it runs properly)
    14·1 answer
  • Which transformation(s) can be used to map ARST onto
    8·1 answer
  • If you wanted to make certain numbers in a spreadsheet stand out, you should _____.
    11·2 answers
  • Although you can use a dialog box to indent paragraphs, word provides a quicker way through the ____.
    7·1 answer
  • 2.1. The stream cipher described in Definition 2.1.1 can easily be generalized to work in alphabets other than the binary one. F
    10·1 answer
  • Relation between training and occupation with examples in points . Plz tell fast<br> ​
    5·1 answer
  • a farmer cultivates 1/4 of his farm with ground nuts and 2/5 of it with maize what is the total landnarea that is cultivated​
    12·1 answer
  • PLEASE HELP ME!!!
    13·1 answer
  • Write two statements that each use malloc to allocate an int location for each pointer. Sample output for given program:
    7·1 answer
  • Which display technology was developed by apple, produces vibrant colors, and supports viewing from all angles?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!