0
Can someone help me with the first project(part 11) under the first section called basic concepts please?
I am unsure how to create the program so that it will receive multiple inputs and have the desired output including where to use the modulo operator.
9 ответов
+ 2
#include <iostream>
using namespace std;
int main() {
//your code goes here
int a;
cin>>a;
int b=50;
if (a<=50){cout<<b-a;}
else {cout<<b-(a%b);}
return 0;
}
here is the answer
+ 1
Hi mate, which programming language are you using?
+ 1
Brian if you post your code in the code playground and link to it here, people can take a look and see what's going on.
+ 1
#include <iostream>
using namespace std;
int main() {
//your code goes here
int totalPassengers = 126;
int busLoad = 50;
int a = busLoad * 2;
int b = 126%a;
int seatsRemaining = busLoad - b;
cout << seatsRemaining;
return 0;
}
0
Did you mean the Transportation code challenge in the C++ course?
If yes you don't need multiple inputs.
1. You will get the amount of passengers. Save it in a variable.
2. Do the calculations and save it. And remember you need to know how many seats from the last bus are empty. With the modulo operator you can get the taken seats from the last bus.
Go back to the basic arithmetic lesson (8.1).
Here is the link:
https://www.sololearn.com/learn/CPlusPlus/1609/?ref=app
There you can read about the modulo operator. In the comments below the lession you can get more informations from the community.
3. After calculations print the result.
Good luck 😉
0
I am working with C++. I think I had it written but the thing is the results window is using specific inputs to use as the total passengers amount so how do I write the program so that no matter what amount of passengers you receive it will be able to calculate the amount of seats remaining? I was able to get the program to work with certain values such as the sample input but not for any input.
0
The challenge description is a little confusing.
If there are more then 50 passengers you have more then 1 bus. For each 50 passengers 1 bus.
For example :
p = passengers
b = busses
101 p = 3 b
49 p = 1 b
So your code is right just take 1 busLoad and change 126 with the users input.
0
I am still stuck. In the results tab there are 2 test cases. How would I construct the code to accept any test case input and output the seats remaining? When I try to code a input stream statement, I get strange results.