+ 2

How can I get this?

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.

28th Feb 2022, 7:48 PM
Jamilu Abubakar Sadiq
Jamilu Abubakar Sadiq - avatar
28 Answers
0
Jamilu Abubakar Sadiq Look like you are using JS 😊 Just write console.log(prices.map(currentPrice => currentPrice + increase))
2nd Mar 2022, 12:56 PM
NonStop CODING
NonStop CODING - avatar
+ 6
Jamilu Abubakar Sadiq int y = 50; x //input cout << y - x % y;
28th Feb 2022, 8:28 PM
A͢J
A͢J - avatar
+ 3
Jackie Manav Roy See this description once "calculate and output how many empty seats the last bus will have." doesn't matter bus will leave or not but seats will be left Here we are not talking about only 1 bus. So if passengers are 50 then last bus will have 50 seats left. On 51 last bus will have 49 seats left On 52 last bus will have 48 seats left.
4th Mar 2022, 6:08 PM
A͢J
A͢J - avatar
+ 2
#include <iostream> using namespace std; int main() { //your code goes here x % y; cout return 0; }
28th Feb 2022, 8:00 PM
Jamilu Abubakar Sadiq
Jamilu Abubakar Sadiq - avatar
1st Mar 2022, 4:11 AM
NonStop CODING
NonStop CODING - avatar
+ 1
Jackie You are using C++ In your else if block, write cout << 50 - (bus%50); https://code.sololearn.com/cECDDyox7s6H/?ref=app
3rd Mar 2022, 4:17 AM
NonStop CODING
NonStop CODING - avatar
+ 1
No Precedence of arithmetic operators. Evaluated first is () then */% then +- So my code doesn't have () so first %will be evaluated then - rule of maths: () then */% then + - https://www.informit.com/articles/article.aspx?p=1705442&seqNum=6
4th Mar 2022, 1:28 PM
Jackie
Jackie - avatar
4th Mar 2022, 2:33 PM
NonStop CODING
NonStop CODING - avatar
0
https://code.sololearn.com/cl4oEmzjnXCO/?ref=app My code does output 50 when entering 0 YOUR CODE outputs 0
4th Mar 2022, 2:38 PM
Jackie
Jackie - avatar
0
Remove the && bus!=0 in YOUR CODE
4th Mar 2022, 2:40 PM
Jackie
Jackie - avatar
0
the question is how many seats left on last trip...so let's say 150 people the bus wil have 3 trips. So if all seats are open for the 4th trip there's no need for a trip. as all will be open and no passengers and this also applies to input 0 if no passengers no trip
4th Mar 2022, 2:44 PM
Jackie
Jackie - avatar
0
Manav Roy No it's 50
4th Mar 2022, 2:44 PM
NonStop CODING
NonStop CODING - avatar
0
Jackie Yeah I included that because I forgot that there is no need for a new bus Fixed it
4th Mar 2022, 2:46 PM
NonStop CODING
NonStop CODING - avatar
0
Manav Roy Jackie close the case👍
4th Mar 2022, 2:48 PM
NonStop CODING
NonStop CODING - avatar
0
int passengers; cin >> passengers ; if(passengers<50 && passengers!=0) { cout<<50 - passengers; } else if(passengers%50!=0) { cout<<50-passengers%50; } return 0;
4th Mar 2022, 3:19 PM
Jackie
Jackie - avatar
0
What is the source of question? I mean is it from solo learn??
4th Mar 2022, 4:18 PM
NonStop CODING
NonStop CODING - avatar
0
Input above code in sololearn and it will be correct
4th Mar 2022, 5:30 PM
Jackie
Jackie - avatar
0
Please people this is closed NO BUS WILL LEAVE IF THERE'S NO PEOPLE
4th Mar 2022, 5:52 PM
Jackie
Jackie - avatar
- 1
You are working on a Store Manager program, which stores the prices in an array. You need to add functionality to increase the prices by the given amount. The increase variable is taken from user input. You need to increase all the prices in the given array by that amount and output to the console the resulting array. function main() { var increase = parseInt(readLine(), 10); var prices = [98.99, 15.2, 20, 1026]; //your code goes here }
2nd Mar 2022, 12:26 PM
Jamilu Abubakar Sadiq
Jamilu Abubakar Sadiq - avatar
- 1
int main() { //your code goes here int bus; cin >> bus; if(bus<=50) { cout<<50-bus; } else if(bus%50!=0) { cout<<50-bus%50; } return 0; }
2nd Mar 2022, 11:41 PM
Jackie
Jackie - avatar