- 5

Ticket office project

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 There's a code below buh I just need an explanation for it thanks

30th Oct 2021, 6:21 PM
Emmanuel Osemudiamen
Emmanuel Osemudiamen - avatar
1 Resposta
- 4
#include <iostream> using namespace std; int main() { int ages[5]; for (int i = 0; i < 5; ++i) { cin >> ages[i]; } //your code goes here float youngest_person, cost ; youngest_person = ages[0]; for (int x = 1; x < 5; ++x) { if ( youngest_person > ages[x]) youngest_person = ages[x]; } cost = 50 - (50*youngest_person/100); cout << cost << '\n'; return 0; }
30th Oct 2021, 6:22 PM
Emmanuel Osemudiamen
Emmanuel Osemudiamen - avatar