0

Help me to code

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

31st Aug 2022, 1:15 PM
Arjun Singh
Arjun Singh - avatar
3 Answers
+ 1
What help you need? Post your try..
31st Aug 2022, 1:35 PM
Jayakrishna 🇼🇳
0
#include <iostream> using namespace std; int main() { int ages[5]; for (int i = 0; i < 5; ++i) { cin >> ages[i]; //your code goes here int min ; min=ages[i]; if (min<ages[i] ) cout<<50-min*50/100; } return 0; }
2nd Sep 2022, 5:54 PM
Arjun Singh
Arjun Singh - avatar
0
Oh. No. You are taking input and comparing with min in same loop. It is works like min = ages[i] ; both same values now then if( min < ages [I] ) never true. Because both values are same. First need to find minimum value then find discount so discount print should be after and out side loop...
2nd Sep 2022, 7:17 PM
Jayakrishna 🇼🇳