Ticket Office C++ Problem
So I'm in the middle of the Ticket Office problem in C++, and I'm having trouble figuring out where I've gone wrong. Here's the premise of the problem: 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 My code works just fine for test cases 1 and 3, but it runs into a weird problem where it just skips over a number for test case 2. Here's my code for reference: #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 = ages[0]; float discount = youngest/100; for (int j = 0; j < 5; j++){ if(youngest > ages[j+1]){ youngest = ages[j]; } } float total = 50-(50*discount); cout << total; return 0; }