import java.util.Scanner; import java.util.*; public class Home { public static void main(String[] args) { int ticketCounter = 0; // Number of tickets sold double moneyCollected = 0; // Sum of money collected int price = 42; // You didn't write what the price is, so I decided.; Scanner input = new Scanner(System.in); // This is for input, probably replaceable with JOptionPane int age; // The age of the person buying a ticket System.out.println("What is your age?"); //JOptionPane again, just presenting the user with some text age = input.nextInt(); // Getting the input and putting it in the age, JOptionPane again while (age != -1) // This is the loop for multiple inputs. If a person writes their age as -1, it stops getting inputs { if (age <=5) { ticketCounter++; // You sold a ticket, add one to the counter System.out.println("That ticket was free");//again, output with JOptionPane. Since it was free there is nothing to add to the amount collected } else if ((6<=age) && (age<=12)) { ticketCounter++; //Sold a ticket moneyCollected+= price*0.5;//Adding half the price of a ticket because of the discount to the sum System.out.println("That ticket was 50% off");//output } else if ((age>=13)&&(age<=54)) { ticketCounter++;//Sold a ticket moneyCollected+=price;//full ticket price System.out.println("That ticket wasn't at a discount");//output } else if(age>=55) { ticketCounter++;//Sold a ticket moneyCollected+=price*0.25;//75% discount System.out.println("That ticket was at a 75% discount");//output } System.out.println("What is your age? (type -1 to stop getting age)");//output age = input.nextInt(); // Getting the new age, which could be -1 which will stop the loop } //Now if someone inputs the age of -1, it stops the loop so you can see how many tickets you sold and what's the sum of money you got System.out.println("You sold "+ticketCounter+" tickets"); System.out.println("You collected "+moneyCollected+" Dollars"); } }