+ 3

How do i Solve this C++ Code coach problem?

I am not able to solve the first project of the C++ course 'Transportation'. Can Anyone please help me solve this problem? This is the link: https://www.sololearn.com/learning/eom-project/1051/902

5th Jan 2021, 12:45 PM
Aditya
Aditya - avatar
7 ответов
+ 7
Hints: --> You can first use the modulus operator (%) to know how many people are there in the LAST BUS Example of % operator: 102 % 50 == 2 // we got 2 which is the remainder of the result --> You can use subraction (-) to calculate the number of FREE SEATS in the LAST BUS - - - - - - - - - - - - - - - - - - - Note that in the problem the expected output is the NUMBER OF FREE SEATS IN THE LAST BUS. - - - - - - - - - - - - - - - - - - - If you encounter some errors or bugs that you cant solve or figure out, just show us your attempt and so we may help you fix it. Thanks and good luck! 🙂
5th Jan 2021, 12:49 PM
noteve
noteve - avatar
+ 3
Can you please tell me that the number of buses is 3 or the value changes depending on the number of passengers?
5th Jan 2021, 2:07 PM
Aditya
Aditya - avatar
+ 2
Aditya You can get the number of passengers in the last bus regardless of the number of buses by the equation passengers % capacity passengers is the input and capacity is the maximum capacity of a single bus which in the problem is 50. The result will become the remaining no. of passengers in the last bus.
5th Jan 2021, 2:35 PM
noteve
noteve - avatar
+ 1
Ok!
5th Jan 2021, 2:56 PM
Aditya
Aditya - avatar
+ 1
I have completed this in my videoes. : https://youtu.be/yCap753OQo4?si=Ijb4vcBEA_NZ0xv4
3rd Oct 2023, 3:32 AM
Ar -Rafiu Ishmam
Ar -Rafiu Ishmam - avatar
0
#include <iostream> using namespace std; int main() { //your code goes here int passenger = 126; int bus =50; int first = passenger % bus; int second = bus - first; cout <<second<<endl; return 0; }
14th Jan 2021, 2:53 AM
Ahadjie Bless
Ahadjie Bless - avatar
0
Hello guys, I don"t understand what is wrong with my code. #include <iostream> using namespace std; #include <iostream> using namespace std; int main() { int bus = 50; int people_waiting ; int empty_seats; int takenseats; int people_left; int people_left_2; cout << ""; cin >> people_waiting; people_left = people_waiting - bus; takenseats = bus% people_left; empty_seats = bus - takenseats; cin >> people_waiting; people_left_2 = people_waiting - bus; takenseats = bus% people_left_2; empty_seats = bus - takenseats; cout << "" << empty_seats << "" << endl; return 0; }
9th Apr 2022, 10:34 AM
Abdessamad Abalhi