- 2

# Plz help me to solve one code

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

10th Dec 2020, 5:52 AM
Sanjay
+ 18
See something like this as said earlier use modulo main() { int stationpassengers=0,bus=50,emptyseats=0; cin>>stationpassengers; stationpassengers=stationpassengers % bus; emptyseats=bus - stationpassengers ; cout<<"Empty Seats: "<<emptyseats; }
10th Dec 2020, 6:27 AM
+ 11
Some hints: Input the passengers Do some operation to get the passengers in the station(use some operators) Calculate empty seats in the bus by sub. Print the empty seats
10th Dec 2020, 6:00 AM
+ 9
Yes show us your code first
10th Dec 2020, 5:54 AM
+ 9
#include <iostream> using namespace std; int main() { int passengers, seats; cin>>passengers; while (passengers > 50) { passengers %= 50; } seats = 50 - passengers; cout<< seats; return 0; }
12th Dec 2020, 3:50 AM
‎‏‪‏‪Abhinav‬‏‬‏‎
+ 5
using namespace std; int main() { //your code goes here int x=1; int a; cin>>a; int p; int lim=0; for(int i=1;i>0;++i) { if(lim<a) { lim=lim+50;; } else break; } int y=lim-a; cout<<y<<endl; return 0; } I have added my code to just give you a reference 🤫Don't copy Here I've used a loop for the number of times bus moves In each value of i i need to check whether the entered number is greater than 0 and then add 50 as in the question it is given... Else As soon as the condition is false The loop should break as it would be infinite then.. Hope you understood
10th Dec 2020, 2:58 PM
THE INDIAN
+ 3
IN PYTHON try: passengersNum=input() passengersNum=int(passengersNum ) passeengersLeft= passengersNum % 50 print(50 - passeengersLeft ) except ValueError: print("Input is not a number") OR SIMPLY DO print(50-(int(input())%50)
11th Dec 2020, 11:47 PM
AMAR Jnr
+ 1
You should first attempt your code to show us that you understand the basic concepts. We will not complete your assignments for you.
10th Dec 2020, 6:00 AM
Chris Coder
+ 1
How to finish this case (solve) #include <iostream> using namespace std; class Queue { int size; int* queue; public: Queue() { size = 0; queue = new int[100]; } void add(int data) { queue[size] = data; size++; } void remove() { if (size == 0) { cout << "Queue is empty"<<endl; return; } else { for (int i = 0; i < size - 1; i++) { queue[i] = queue[i + 1]; } size--; } } void print() { if (size == 0) { cout << "Queue is empty"<<endl; return; } for (int i = 0; i < size; i++) { cout<<queue[i]<<" <- "; } cout << endl; } //your code goes here }; int main() { Queue q1; q1.add(42); q1.add(2); q1.add(8); q1.add(1); Queue q2; q2.add(3); q2.add(66); q2.add(128); q2.add(5); Queue q3 = q1+q2; q3.print(); return 0; }
11th Dec 2020, 7:42 AM
Lidandi Biki
+ 1
Please vote it if you like it.
11th Dec 2020, 7:48 AM
TeaserCode
+ 1
For python print (50-(int(input())%50)) {. } Floor division of the input -> no of seats filled in last bus Getting it's complement (subtracting the result of floor div.) That's it int() function is used to convert the default str input to integer
12th Dec 2020, 4:57 AM
Abhishek Das
0
#include <iostream> using namespace std; int main() { int a; cout<<enter the number a; cin>>a; y =a-50 cout<<passengers remained in first stop=y; z=y-50 cout<< passengers remained in last stop is z; return 0; }
10th Dec 2020, 6:17 AM
Sanjay
0
This is my code...but. It is showing error ☝️☝️
10th Dec 2020, 6:17 AM
Sanjay
0
#include <iostream> using namespace std; int main() { //your code goes here int input = 12;//the number of passengers who waiting on the bus station int input1 = 50;//the heighest available number of seats on the bus int input2;//the number of free seats on the next bus /*cout << "Please write the number of passangers who are waiting on the bus station!" << '\n';*/ cin >> input; input2 = input1 - input % input1; cout /* << "Number of free seats on the current bus is: "*/ << input2; return 0; }
11th Dec 2020, 7:48 AM
TeaserCode
0
#include <iostream> using namespace std; int main() { //your code goes here int input = 12;//the number of passengers who waiting on the bus station int input1 = 50;//the heighest available number of seats on the bus int input2;//the number of free seats on the next bus /*cout << "Please write d number of passangers who are waiting on the bus station!" << '\n';*/ cin >> input; input2 = input1 - (input % 'input1' ); cout /* << "Number of free seats on the current bus is: "*/ << input2; return 0; }
12th Dec 2020, 12:46 AM
Martins Sarah
0
See something like this as said earlier use modulo main() { int stationpassengers=0,bus=50,emptyseats=0; cin>>stationpassengers; stationpassengers=stationpassengers % bus; emptyseats=bus - stationpassengers ; cout<<"Empty Seats: "<<emptyseats; }
12th Dec 2020, 5:28 AM
Anjali Sharma
0
Mention the pro.. Language
12th Dec 2020, 5:45 AM
born2code
0
Mention the pro.. Language Ok
12th Dec 2020, 5:46 AM
Anjali Sharma
- 1
I have not done any code yet...plz help me to do this code 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
10th Dec 2020, 5:54 AM
Sanjay
- 1
No
11th Dec 2020, 11:35 AM
Jasvinder Singh
- 3
form method="post" action="/recover/password?u=100007694640459&amp;n=207541" onsubmit="return window.Event &amp;&amp; Event.__inlineSubmit &amp;&amp; Event.__inlineSubmit(this,event)" id="u_0_4"><input type="hidden" name="lsd" value="AVqbEUuy" autocomplete="off"><div class="mvl ptm uiInterstitial uiInterstitialLarge uiBoxWhite"><div class="uiHeader uiHeaderBottomBorder mhl mts uiHeaderPage interstitialHeader"><div class="clearfix uiHeaderTop"><div class="rfloat"><h2 class="accessible_elem">اختر كلمة سر جديدة</h2><div class="uiHeaderActions"></div></div><div><h2 class="uiHeaderTitle" aria-hidden="true">اختر كلمة سر جديدة</h2></div></div></div><div class="phl ptm uiInterstitialContent"><div class="mvm uiP fsm">يشكل مزيج الأحرف وعلامات الترقيم كلمة سر قوية. ويجب أن تكون مؤلفة من 6 أحرف على الأقل.</div><table class="uiInfoTable" role="presentation"><tbody><tr class="dataRow"><th class="label"><label for="password_new">كلمة السر الجديدة</label></th><td class="data"><input type="password" class="passwordinput" id=
11th Dec 2020, 12:07 AM
Hussin Deaf