Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I add a while loop to the c + + programming below? Also how do I add a variable so it shows the

How do I add a while loop to the c++ programming below? Also how do I add a variable so it shows the minYear as 1900 and maxYear as 2024?
#include
using namespace std;
int main()
{
cout << "Please enter your birth year: ";
cin >> year;
if (year >=1936 && year <=2055)
break;
cout << "The year must be from 1936 to 2055, please try again!
";
//Calculate user's zodiac and write program to display the proper sign
switch (year%12)
{
case 0:
cout << "Your chinese zodiac sign is the rat! "<< endl;
cout << "Rats are very popular!" << endl;
break;
case 1:
cout << "Your chinese zodiac sign is the ox!"<< endl;
cout << "Oxes are dependable and calm!" << endl;
break;
case 2:
cout << "Your chinese zodiac sign is the tiger! "<< endl;
cout << "Tigers are brave and respected!" << endl;
break;
case 3:
cout << "Your chinese zodiac sign is the rabbit! "<< endl;
cout << "Rabits are nice to be around!" << endl;
break;
case 4:
cout << "Your chinese zodiac sign is the dragon! "<< endl;
cout << "Dragons are known for their good health and having lots of energy!" << endl;
break;
case 5:
cout << "Your chinese zodiac sign is the snake! "<< endl;
cout << "Snakes are good with money!" << endl;
break;
case 6:
cout << "Your chinese zodiac sign is the horse! "<< endl;
cout << "Horses are popular, cheerful, and quick to compliment others!" << endl;
break;
case 7:
cout << "Your chinese zodiac sign is the goat! "<< endl;
cout << "Goats are known for being great artists!" << endl;
break;
case 8:
cout << "Your chinese zodiac sign is the monkey! "<< endl;
cout << "Monkeys are very funny and good problem solvers!" << endl;
break;
case 9:
cout << "Your chinese zodiac sign is the rooster! "<< endl;
cout << "Roosters are talented and hard working!" << endl;
break;
case 10:
cout << "Your chinese zodiac sign is the dog! "<< endl;
cout << "Dogs are very loyal and can keep a secret!" << endl;
break;
case 11:
cout << "Your chinese zodiac sign is the pig! "<< endl;
cout << "Pigs are good students, honest and brave!" << endl;
break;
}
system("pause");
return 0;
}

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

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions