0

please help, only 4 tests from 5 c++

please help with a code. it works with 4 tests from 5. but dont know what is wrong the question is: You are working on a ticketing system. A ticket costs $10. The office is running a discount campaign: each group of 5 people is getting a discount, which is determined by the age of the youngest person in the group. You need to create a program that takes the ages of all 5 people as input and outputs the total price of the tickets. Sample Input: 55 28 15 38 63 Sample Output: 42.5 The youngest age is 15, so the group gets a 15% discount from the total price, which is $50 - 15% = $42.5 #include <iostream> using namespace std; int main() { float ages[5]; for (int i = 0; i < 5; ++i) { cin >> ages[i];} float a= ages[0]; float q= ages[1]; float e= ages[2]; float r= ages[3]; float u= ages[4]; float b= 50; float d= 100; float c= b/d; float g= c*a; float j= b-g; float t= c*u; float h= b-t; float w= c*q; float s= b-w; float z= c*e; float n= b-z; float y= c*r; float l= b-y; if (a<r && a<q && a<e && a<u){ cout << j;} if (u<a && u<q && u<e && u<r){ cout << h;} if (q<a && q<r && q<e && q<u){ cout << s;} if (r<a && r<q && r<e && r<u){ cout << l;} if (e<a && e<q && e<r && e<u){ cout << n;} return 0; } return 0; }

13th Dec 2020, 1:34 PM
Саша Топалиди
Саша Топалиди - avatar
5 ответов
+ 4
Саша Топалиди No need to write complex code. You just have to find minimum value from the array . int min = ages[0]; for (int i = 0; i < 5; i++) { if (min > ages[i]) { min = ages[i]; } } double result = 50 - min * 15 / 100;
13th Dec 2020, 2:02 PM
A͢J
A͢J - avatar
+ 3
I Am Groot ! Just nailed it 😂😂
13th Dec 2020, 2:05 PM
Alphin K Sajan
Alphin K Sajan - avatar
+ 2
Саша Топалиди Could u post the Question and tag the language
13th Dec 2020, 1:35 PM
Alphin K Sajan
Alphin K Sajan - avatar
0
yes , I 've wrote a question, sorry
13th Dec 2020, 1:38 PM
Саша Топалиди
Саша Топалиди - avatar
0
I Am Groot ! thank you!!!! very much!!
13th Dec 2020, 2:16 PM
Саша Топалиди
Саша Топалиди - avatar