+ 1

Pls help me in solving this

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

4th May 2021, 8:45 AM
Aanya Singhania
Aanya Singhania - avatar
4 Respuestas
+ 2
Thanks aj anant
4th May 2021, 1:10 PM
Aanya Singhania
Aanya Singhania - avatar
+ 1
#include <iostream> using namespace std; int main() { int ages[5],min=1000,total=50; float fin,dis; for (int i = 0; i < 5; i++) { cin >> ages[i]; } for (int i = 0; i < 5; i++) { if(min>ages[i]) min=ages[i]; } dis=(min/100)*total; fin=total-dis; cout<<fin; return 0; } My attempt
4th May 2021, 8:56 AM
Aanya Singhania
Aanya Singhania - avatar
+ 1
Aanya Singhania Why there is min initialised with 1000? Just initialise it with 0 and store 1st value in min and get min age from ages by just doing this comparison if (min > ages[i]) { min = ages[i]; } Make total variable to float not int float total = 50.0; https://code.sololearn.com/crJYG9bRXq5K/?ref=app
4th May 2021, 9:50 AM
A͢J
A͢J - avatar
0
Aanya Singhania Where is your attempts?
4th May 2021, 8:55 AM
A͢J
A͢J - avatar