+ 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.
20 Respostas
0
Jamilu Abubakar Sadiq
Look like you are using JS š
Just write
console.log(prices.map(currentPrice => currentPrice + increase))
+ 6
Jamilu Abubakar Sadiq
int y = 50;
x //input
cout << y - x % y;
+ 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.
+ 2
#include <iostream>
using namespace std;
int main() {
//your code goes here
x % y;
cout
return 0;
}
+ 1
Jamilu Abubakar Sadiq
Solved
Write this way mateš¤
https://code.sololearn.com/c0aDQzOov3BG/?ref=app
+ 1
Jackie
You are using C++
In your else if block, write
cout << 50 - (bus%50);
https://code.sololearn.com/cECDDyox7s6H/?ref=app
+ 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
0
https://code.sololearn.com/cl4oEmzjnXCO/?ref=app
My code does output 50 when entering 0 YOUR CODE outputs 0
0
Remove the && bus!=0 in YOUR CODE
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
0
Manav Roy
No it's 50
0
Jackie
Yeah I included that because I forgot that there is no need for a new bus
Fixed it
0
int passengers;
cin >> passengers ;
if(passengers<50 && passengers!=0)
{
cout<<50 - passengers;
}
else if(passengers%50!=0)
{
cout<<50-passengers%50;
}
return 0;
0
What is the source of question?
I mean is it from solo learn??
0
Input above code in sololearn and it will be correct
0
Please people this is closed NO BUS WILL LEAVE IF THERE'S NO PEOPLE
- 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
}
- 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;
}