# I know Im bad at math T^T I need your help

#include <iostream> using namespace std; int main() { //your code goes here int passengers = 0; //cout << "Enter passengers: "; cin >> passengers; int seats = (250 - passengers) % 50; cout << seats; return 0; } test case 1,2,3 and 5 r okay except for case 4. what program does is it outputs available seats in the bus. the bus can only transport 50 passengers at once. one thing ive noticed in my program is when the input is 100, the output is 0. and I know why 😆 the output should be 150. I just cant think other solution.

2/27/2021 11:40:57 AM

Sora22 Answers

New AnswerDon't forget to account for the case when the number of passengers is a multiple of 50. If there were 200 passengers then 200 % 50 is zero. Thus 50 - 0 is 50. You don't want to send an empty bus out. Hint, use an if statement.

1. Try to use modulus operator to the total passengers and max capacity to get the number of passenger in LAST BUS. 2. Then subtract it by 50 to get the FREE or REMAINING SEATS. 50 - (passengers % 50)

That's it, I understand the task! imagine the total number of passengers for example 176 people. one bus carries 50 people at a time. we need to calculate the number of available seats only in the last bus. so we need to subtract from 176 three times 50 (three buses will leave full). and total number of seats last we need to deduct the remainder 176 - 150

#include <iostream> using namespace std; int main() { //ваш код int bus = 50; int people; cin >> people; int val = people % bus; int va = bus - val; cout << va; }

Hi! instead of 250, you should use a variable - the total number of passengers

Arsenic 250 is the total (available seats. - passengers) % 50 . ive been thinking for an hour how to solve that 😆. 250 = 5 buses. so if my input is 23 the output should be 27 cos each bus has only 50 seats. sorry my english is bad

#include <iostream> int main(){ const int max_passengers = 50; int num_of_passengers; std::cin >> num_of_passengers; int temp = (num_of_passengers % max_passengers); temp = max_passengers - temp; std::cout << temp << std::endl; return 0; } try this code.. it works for me..

In my opinion we must write the code conform to the user requirements. We just need to give improvement advice in case the business process and result expected not confirm. Except stated others. I write my code int empty_seats = passengers%50. It passed all test case. But in Loan calculator, my code only passed 3 of 5 test case. Confusing. The same thing is also happens in new driving license code. I passed 4 of total overall 5.

Hi! so you passed the credit calculator and the driver's license? can I see your code? In what language do you decide?

Martin Taylor I think that will just be fine even if the input is multiple of 50. Because the problem is asking for the free seats in the last bus, it is okay to have 50 free seats, (full capacity). 50 - (passengers % 50) 50 - (200 % 50) 50 - 0 = 50 It means that the last bus has 50 seats available, so we can still wait for the 50 passengers. EDIT: I think you're right if it is from her formula. (passengers - 200) % 50 (250 - 200) % 50 50 % 50 = 0

The point' is to determine number of empty seat in the last bus. You must remember that for every departure to the destination, bus always take a maximum passengers can be transported, which equal to 50 passenger. If bus total capacity 50 then available total passengers is less than capacity, bus only transport total passengers on only one departure and there is a Remaining empty seats 50-total Passengers waiting in queue to be transported to the destination. If Passengers is > 50 say 51, thus there will be 2 time departure which means there are 2 busses will transport the passenger, and the last bus only transport 1 passenger. So there are 50-1 or 49 empty seats remaining in the last bus departure. Thank you.

Math is easy only find your interest and start learning it because in coding this subjects are most helpful: ( I ) Physics ( II ) Chemistry ( III ) Math😉😉☺️☺️☺️😄😄😄😄😄😄☺️☺️😉😉😉