//Name: Dylan Trevino
//
// This program determines the total COST of movie tickets, snacks, and taxes.
// A child's ticket cost is 60% of an adult ticket cost. Every one gets the same type of snack.
// Taxes must be collected on the cost of the snacks ONLY.
import java.util.*;
public class MovieBill {
// final double TAXRATE = .0825;
// Cannot be referenced from static context, placed instead in: static main
public static void main( String[] args ) {
Scanner reader = new Scanner (System.in);
final double TAXRATE = .0825;
int children = 0;
int adults = 0;
// Input variables
double costPerTicket = 0.0;
double costPerSnack = 0.0;
// Calculation variables
int people = 0;
double adultCost = 0.0;
double childCost = 0.0;
double costOfTickets = 0.0;
double costOfSnacks = 0.0;
double taxes = 0.0;
double totalBill = 0.0;
// Inputs
System.out.println("Enter the number of children attending");
children = reader.nextInt();
System.out.println("Enter the number of adults attending");
adults = reader.nextInt();
System.out.println("Enter the ticket COST of an adult");
costPerTicket = reader.nextDouble();
System.out.println("Enter the cost of one SNACK ");
costPerSnack = reader.nextDouble();
// Calculations
people = adults + children;
adultCost = adults * costPerTicket;
childCost = children * (costOfTickets * 0.6);
costOfTickets = adultCost + childCost;
costOfSnacks = people * costPerSnack;
taxes = costOfSnacks * TAXRATE;
totalBill = costOfTickets + taxes;
// Output
System.out.println();
System.out.println("Number of adults: " + adults);
System.out.println("Number of children: " + children);
System.out.println("Total number of people: " + people);
System.out.printf("Total Cost of Tickets:%8.2f \n", costOfTickets);
System.out.printf("Total cost of Snacks (plus Taxes):%8.2f \n", taxes);
System.out.printf("Total:%8.2f \n" , totalBill);
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: