0

How do you complete 12 code project Transport

4th Jun 2021, 10:15 PM
Drei C
Drei C - avatar
4 Respuestas
+ 2
Please post the question as well as your code
5th Jun 2021, 6:58 AM
Atul [Inactive]
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 2021, 8:32 PM
Drei C
Drei C - avatar
0
Post your attempt pls
6th Jun 2021, 5:16 AM
Atul [Inactive]
0
Hi there. in this case you need to have few lines. first do the remainder using % and finally use the - minus to get seats left. it confused me asl well as i thought a single line is enough. answer declare the variables first int seats = 0 ; int waiting = 0 ; cin >> waiting ; //have to include this one apparently as user input, otherwise it wont work. dont need to add cin >> seats because seats are the answer for the equation formula. just cin >> waiting , so user can input any number an get result seats = waiting % 50 ; //for all the earlier bus to take passengers to get the remainder for seats left for the last bus cout << seats - 50 << endl ; // number of seats left Imo dont get caugh up with the explanation too much it might confused you. Happy learning
2nd Nov 2021, 12:08 AM
Unclejo