0

Guys I can't pass the end of module project I don't know what is wrong with my code please someone help me

#include <iostream> using namespace std; int main() { //your code goes here int w , x , y ; w = 12 ; x = 50 ; y = x - w ; cout << y << endl ; int z ,b ,a , c ; z = 231 ; b = 50 ; a = z % b ; c = b - a ; cout << c ; return 0 ; }. It always gets the output of 38 19 Instead of inserting the 38 to case #1 And the 19 to case #2 It inserts both numbers to both cases.

21st Mar 2021, 12:25 PM
Norhan El-zomor
Norhan El-zomor - avatar
5 Answers
+ 4
You need to declare no of passengers as an input variable instead of declaring many variables with values cin>>w; /*or x/y/z/a/b/c/d....*/
21st Mar 2021, 12:41 PM
Simba
Simba - avatar
+ 2
First understand the problem.. It need to take a input for number of passengers... so first know input taking.. Ex: If input is 126 and seats are total 50. So 126-50 = 76 (full seats 1st trip) 76-50=26( full, 2nd trip) 26-50= -24 (24 seats are empty..) Output 24. Simple: 50 - 126%50 You have program for this.. Store input, (if you want seats=50) find empty=? Input is different every time. So calculate output depends on input. Can you try again...?
21st Mar 2021, 12:40 PM
Jayakrishna 🇼🇳
+ 2
Thank you both simba and jaya so much i have solved it i didn't take notice that they have wanted a program not an equation for any case
21st Mar 2021, 1:24 PM
Norhan El-zomor
Norhan El-zomor - avatar
+ 1
Is that not same output? Post full description of problem..
21st Mar 2021, 12:28 PM
Jayakrishna 🇼🇳
+ 1
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.
21st Mar 2021, 12:29 PM
Norhan El-zomor
Norhan El-zomor - avatar