What I'm I doing wrong/ they are telling me I'm close but I don't get it | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What I'm I doing wrong/ they are telling me I'm close but I don't get it

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. My code is Int main () { Int thebus = 50; Int station = 126; Int sum = ( station - thebus) - thebus Cout << thebus % sum; } Return 0;

27th Dec 2020, 10:46 AM
Ali
Ali - avatar
1 Answer
+ 7
Random Stuff , this task can be done like this: ▪︎take an input for total number of passengers at the station ▪︎do a modulo division with total passengers e.g. 126 and max seats in bus = 50 and store this remainder ▪︎ subtract 50 - remainder ->> this is the requested solution happy coding!
27th Dec 2020, 11:46 AM
Lothar
Lothar - avatar