0

I have a mistake on my last code can someone help

Last cop project of mine https://code.sololearn.com/cyUUsp6cY94K/?ref=app

12th Dec 2021, 12:03 PM
Lalala
Lalala - avatar
2 Answers
+ 3
> cin >> speed; //is missing to take in the value for speed > Your switch cases is expecting a char so 'b' , 'c', and 'r' instead of b, c, r //corrections #include <iostream> using namespace std; int main() { int speed ; char vehicle ; cout << "(Bus: b Car: c Rocket: r)\n" ; cout << "Vehicle :\n" ; cin >> vehicle; cout << "What's your speed?? \n" ; //Corrections ++++++++++++++++++++++++++++++++++++++++++++++++++++++ cin >> speed; switch (vehicle){ case 'b': //character 'b' not b +++++++++++++++++++++ cout << "You're driving a BUS." ; if (speed > 70){ cout << "You're driving too fast for a bus." ; } else if (speed < 40){ cout << "You're driving too slow for a bus." ; } else cout << "Perfect speed for bus :=)" ; break ; case 'c': // +++++++++++++++++++++ cout << "You're driving a CAR."; if (speed > 100){ cout << "You're driving too fast for a car." ; } else if (speed < 50){ cout << "You're driving too slow for a car." ; } else cout << "Perfect speed for car :=)" ; break ; case 'r': // +++++++++++++++++++++ cout << "You're driving a ROCKET????."; if (speed > 50 && speed < 200){ cout << "They see me rollin'. How to drive your Rocket " ; } else if (speed < 50){ cout << "Bet your Rocket still in factory." ; } else cout << "Time to fly to the moon..." ; break ; default: cout << "????" ; } return 0; }
12th Dec 2021, 12:43 PM
Ifeanyichukwu Otiwa
+ 9
You missed to give a value to speed variable. Also, missed to define switch cases case 'b'...
12th Dec 2021, 12:30 PM
Simba
Simba - avatar