+ 3

C++ Module 1 transport project.

I am struggling to work out what the app is looking for here. Below is my code. #include <iostream> using namespace std; int main() { //Module 1 project int pax; int cap; int lastbusload; int lastbusemptyseats; cap = 50; pax = 126; lastbusload = pax % cap; lastbusemptyseats = cap - lastbusload; cout << "the last bus will have " << lastbusemptyseats <<" seats remaining"; return 0; } It comes up with input 12 expected output 38. I don't understand where it got 12 from.

4th Feb 2021, 3:21 AM
Patrick Millican
Patrick Millican - avatar
4 Respostas
+ 2
pax variable should be inputted. Use cin >> pax instead of pax = 126.
4th Feb 2021, 3:59 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
Patrick Millican 1 - Program will not ask for inputs because inputs are already given in test cases. 2 - Don't print anything else except only value. Just print like this cout << lastbusemptyseats;
4th Feb 2021, 4:14 AM
A͢J
A͢J - avatar
+ 1
Thanks for the help. Atleast I was on the right track with it!
4th Feb 2021, 4:23 AM
Patrick Millican
Patrick Millican - avatar
0
That doesn't help... It doesn't even ask for the input when you run the code if you use cin. #include <iostream> using namespace std; int main() { //Module 1 project int pax; int cap; int lastbusload; int lastbusemptyseats; cin >> pax; cap = 50; lastbusload = pax % cap; lastbusemptyseats = cap - lastbusload; cout << "the last bus will have " << lastbusemptyseats <<" seats remaining"; return 0; }
4th Feb 2021, 4:03 AM
Patrick Millican
Patrick Millican - avatar