0
You are making a program for a bus service. A bus can transport 50 passengers at once. Given the number of passengers waitin
Halp
26 ответов
+ 4
😅😅😅What a complexity, the answer is simple
+ 1
They want the result of the number of riders in the bus and the rest. How do I write the rest in the kut?
+ 1
#include <iostream>
using namespace std;
int main() {
int station = 50;
int passengers,empty;
cin>>passengers;
if (passengers<50){
empty = 50-passengers;}
else{
empty = (passengers % station);}
cout << empty;
return 0;
}
//Moayed Yassr
+ 1
#include <iostream>
using namespace std;
int main() {
//your code goes here
int x;
x=50;
cin>>x;
cout<<50-(x%50)<<endl ;
return 0;
}
+ 1
Moayed Yassr it appears you didn't get your answer but maybe this will help as you are looking for the amount of empty seats ..
Each bus ( meaning that there could be more than one bus ) carries 50 passengers.
There are 126 people waiting which obviously means more than one bus is required.
So let's start out figuring how many busses we are going to need
psgrs = 126
bus = 50
number_of_busses = psgrs / bus
or
empty_seats = psgrs % bus
Here is a quick example I tossed together in PHP which might help you with your cpp question
https://code.sololearn.com/wkuEXM6U3qcn/?ref=app
+ 1
You simply use the modulus operator to get the total number of passengers that took off with the last bus. Afterwards, you subtract from 50 (or bus capacity) to get the number of empty seats
0
What exactly do you need help with? Do you have a code attempt that you have bugs in?
0
Code in c++
0
Right, but what's YOUR code? You didn't even say the complete task so we can't help with such limited information, plus we are not here to give you the answers, but rather help you see what you may have done wrong.
0
#include <iostream>
using namespace std;
int main() {
//your code goes here
int x;
int y;
y=12;
x=50;
cin>>x;
cout<<x-y<<endl ;
return 0;
}
0
What is the problem
0
Can you state the full problem as well? It is getting cut off in the title.
0
You are making a program for a bus service.
A bus can transport 50 passengers at once.
Given the number of passengers waiting in the bus station as input, you need to calculate and output how many empty seats the last bus will have.
Sample Input:
126
Sample Output:
24
Explanation: The first bus will transport 50 passengers, leaving 126-50=76 in the station. The next one will leave 26 in the station, thus, the last bus will take all of the 26 passengers, having 50-26=24 seats left empty.
0
The rest, how do you get it?
0
It looks like there's something a bit wrong with your logic. Why are you assigning the bus capacity and the user's input to the same variable?
I would suggest writing some pseudocode before jumping right into the code. For example:
//Get the input from user
//Create a loop that ends once the bus is UNDER capacity
//Within the loop, subtract bus capacity from input
//Print remaining input
0
Thank you very much, may God bless you with good health
0
LOL no problem and thanks for the blessing. 😆
0
Check this out .This might help you.
#include <iostream>
using namespace std;
void main() {
int station = 50;
int passenger, vacant;
cout << "Enter total number of passengers on the station\n";
cin >> passenger;
if (passenger < 50) {
vacant = 50 - passenger;
}
else
vacant = (passenger % station);
cout << "The last bus to leave station with empty seats would be ";
cout << vacant;
}
0
This is the solution
0
The programming language is not php, it's c++
\\brofar