+ 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.
4 odpowiedzi
+ 2
pax variable should be inputted. Use cin >> pax instead of pax = 126.
+ 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;
+ 1
Thanks for the help. Atleast I was on the right track with it!
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;
}