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

Respuesta :

Answer:

Explanation:

The following program is written in Java. It takes 5 inputs of int values for the ages of each member in the group. Then it loops through all of the ages and chooses the youngest age. Finally, it applies that age as a discount to the final price which would be $50, outputting the final discounted price. The output for the test case provided can be seen in the attached picture below in red.

import java.util.Scanner;

class Brainly

{

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int[] person = new int[5];

       System.out.println("Enter age of individual 1: ");

       person[0] = in.nextInt();

       System.out.println("Enter age of individual 2: ");

       person[1] = in.nextInt();

       System.out.println("Enter age of individual 3: ");

       person[2] = in.nextInt();

       System.out.println("Enter age of individual 4: ");

       person[3] = in.nextInt();

       System.out.println("Enter age of individual 5: ");

       person[4] = in.nextInt();

       int youngest = person[0];

       for (int x = 0; x < person.length; x++) {

           if (person[x] < youngest) {

               youngest = person[x];

           }

       }

       double discount = 1 - (((double)youngest) / 100);

       double output = 50 * discount;

       System.out.println("Total Price: " + output + " the youngest is " + youngest);

   }

}

Ver imagen sandlee09