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

5th Jun 2022, 2:56 PM
Moayed Yassr
Moayed Yassr - avatar
26 Antworten
+ 4
😅😅😅What a complexity, the answer is simple
6th Jun 2022, 10:49 AM
Moayed Yassr
Moayed Yassr - avatar
+ 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?
5th Jun 2022, 3:16 PM
Moayed Yassr
Moayed Yassr - avatar
+ 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
5th Jun 2022, 5:51 PM
Mihir Lalwani
Mihir Lalwani - avatar
+ 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; }
6th Jun 2022, 10:49 AM
Moayed Yassr
Moayed Yassr - avatar
+ 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
6th Jun 2022, 8:25 PM
BroFar
BroFar - avatar
+ 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
7th Jun 2022, 11:17 AM
Success
Success - avatar
0
What exactly do you need help with? Do you have a code attempt that you have bugs in?
5th Jun 2022, 3:04 PM
Justice
Justice - avatar
0
Code in c++
5th Jun 2022, 3:05 PM
Moayed Yassr
Moayed Yassr - avatar
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.
5th Jun 2022, 3:07 PM
Justice
Justice - avatar
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; }
5th Jun 2022, 3:12 PM
Moayed Yassr
Moayed Yassr - avatar
0
What is the problem
5th Jun 2022, 3:14 PM
Moayed Yassr
Moayed Yassr - avatar
0
Can you state the full problem as well? It is getting cut off in the title.
5th Jun 2022, 3:15 PM
Justice
Justice - avatar
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.
5th Jun 2022, 3:18 PM
Moayed Yassr
Moayed Yassr - avatar
0
The rest, how do you get it?
5th Jun 2022, 3:20 PM
Moayed Yassr
Moayed Yassr - avatar
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
5th Jun 2022, 3:26 PM
Justice
Justice - avatar
0
Thank you very much, may God bless you with good health
5th Jun 2022, 3:30 PM
Moayed Yassr
Moayed Yassr - avatar
0
LOL no problem and thanks for the blessing. 😆
5th Jun 2022, 3:35 PM
Justice
Justice - avatar
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; }
6th Jun 2022, 10:24 AM
Hashir Afzal
Hashir Afzal - avatar
0
This is the solution
6th Jun 2022, 10:51 AM
Moayed Yassr
Moayed Yassr - avatar
0
The programming language is not php, it's c++ \\brofar
6th Jun 2022, 8:56 PM
Moayed Yassr
Moayed Yassr - avatar