Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago