Need help with a problem. Can you guys give me some pointers with my code? The question is: 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.
Everything works fine except for when I press 0 to end the program. It's supposed to only say "Program complete". Instead, it says "Your car is OK" AND "Program complete".
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
|
#include <iostream>
using namespace std;
int main()
{
int model;
do {
cout << "Enter your model number (0 to quit): " << endl;
cin >> model;
if (model != 119 && model != 179 && model != 189 && model != 190 && model != 191 && model != 192 && model != 193 && model != 194 && model != 195 && model != 221 && model != 780)
cout << "Your car is OK" << endl;
else
cout << "Your car is defective. Please have it fixed" << endl;
}while (model != 0);
cout << "Program complete" << endl;
cin.get();
cin.get();
return 0;
}
|