0

Can someone help

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.

15th Jul 2021, 9:29 PM
Jeremiahgustusjunior
Jeremiahgustusjunior - avatar
7 odpowiedzi
+ 4
Hint: if you use the modulo operator, it will return the remainder. I.E. 126 % 50 = 26 You then just need to subtract this number from the total number of seats on a bus to find the number of remaining available seats on the last bus.
15th Jul 2021, 9:38 PM
ChaoticDawg
ChaoticDawg - avatar
17th Jul 2021, 3:56 PM
Parth Shendge
+ 1
Jeremiahgustusjunior 1. Get the input (cin) value as an int. Where you have 126 in your expression you should have the variable name for the input value. 2. Remove the quotes from around the variable y in the cout statement. "y" will output y as a String and not the value held by the variable y as intended.
15th Jul 2021, 10:05 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Dude that was very helpful .....fixed errors..thanks
18th Jul 2021, 1:04 PM
Jeremiahgustusjunior
Jeremiahgustusjunior - avatar
0
Cool thanks
15th Jul 2021, 9:40 PM
Jeremiahgustusjunior
Jeremiahgustusjunior - avatar
0
#include <iostream> using namespace std; int main() { //your code goes here int y; y = 50-126%50; cout <<"y"<<endl; return 0; }
15th Jul 2021, 9:55 PM
Jeremiahgustusjunior
Jeremiahgustusjunior - avatar
0
Wats my bug there if I may ask
15th Jul 2021, 9:55 PM
Jeremiahgustusjunior
Jeremiahgustusjunior - avatar