Question
Hello please help with my homework. In c++ I have a slight bug for my getline(cin,dep_city) I'm not sure why it is not taking input
Hello please help with my homework. In c++ I have a slight bug for my getline(cin,dep_city)
I'm not sure why it is not taking input when I compile I added comments to see the error quicker.
Please help thank you
#include
#include
using namespace std;
int main() {
int first_class;
int business_class;
int economy_class;
string destination_city, dep_city;
// a = the crew and the pilot on board.
int total_passengers;
int a = 5;
int b = 205;
int c = 100;
double percentage;
cout << "How many first class passengers are boarding: ";
cin >> first_class;
cout << "How many business class passengers are boarding: ";
cin >> business_class;
cout << "How many economy class passengers are boarding: ";
cin >> economy_class;
std::cout << "Enter departure_city: "< std::getline(std::cin, dep_city); // not taking input cout << "Enter destination city: "; getline(cin, destination_city); std::cout << destination_city << std::endl; total_passengers = first_class + business_class + economy_class; percentage = (total_passengers / b) * c; cout << "The flight from " << dep_city << " to " << destination_city << " will have " << total_passengers << " passengers " << " (" << a + total_passengers << " souls on board)" << " and will be" << percentage << "full" << endl; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started