The Bored Auto Company has done it again. Some models of their cars may be difficult to
drive because their wheels are not exactly round. Cars with model numbers 119, 179, 189
through 195, 221, and 780 have been found to have this defect. Write a program that allows
customers to enter the model number of their car to find out whether or not it is defective.
The program should terminate when a zero is entered as a model number. The program output
should look similar to:
Enter your model number (0 for done): 127
Your car is OK.
Enter your model number (0 for done): 221
Your car is defective. Please have it fixed.
Enter your model number (0 for done): 0
Program complete.
How do I make it so it will repeat until you input 0?
This is what I have. Thanks!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include <iostream>
using namespace std;
int main()
{
int M;
const int GiveUp=0;
cout<<"Enter your model number ("<<GiveUp<<" for done): ";
cin>>M;
if(M == GiveUp)
cout<<"Program complete.";
else if (M == 119 || M == 179)
cout<<"Your car is defective. Please have it fixed.";
else if (M >= 189 && M <= 195)
cout<<"Your car is defective. Please have it fixed.";
else if (M == 221 || M == 780)
cout<<"Your car is defective. Please have it fixed.";
else if(M>GiveUp)
cout<<"Your car is OK.";
return(0);
}
|