mitchwag17
10/19/2018 - 2:34 PM

BoxOffice.java

public class BoxOffice {

	String location, seatlocation, username;
	double numTix;
	double subtotal, salestax, total;

	public BoxOffice() // default constructor
	{

	}

	public void getName(String name) {
		username = name;
	}

	public void getNumTix(int tix) {
		numTix = tix;
	}

	public void getLocation(String loc) {
		seatlocation = loc;
	}

	public String sendMessage() {
		if (seatlocation.equalsIgnoreCase("b"))
			location = "Box";
		else if (seatlocation.equalsIgnoreCase("l"))
			location = "Lawn";
		else if (seatlocation.equalsIgnoreCase("p"))
			location = "Pavilion";

		// create concatenation string thanking user for purchase
		// (Kevin, thank you for purchasing 3 Lawn tickets)
		return (username + ", thank you for purcahsing " + numTix + " "
				+ location + " tickets.");
	}

	public double calcSubtotal() {
		final double BOX = 75.00;
		final double LAWN = 25.00;
		final double PAVILION = 30.00;

		if (seatlocation.equalsIgnoreCase("b"))
			subtotal = numTix * BOX;
		else if (seatlocation.equalsIgnoreCase("l"))
			subtotal = numTix * LAWN;
		else if (seatlocation.equalsIgnoreCase("p"))
			subtotal = numTix * PAVILION;

		return subtotal;
	}

	public double calcSalesTax() {
		final double TAX_RATE = 0.06;
		// calculate salestax
		salestax = subtotal * TAX_RATE;
		// return salestax
		return salestax;
	}

	public double calcTotal() {
		// calculate total
		total = subtotal + salestax;
		// return total
		return total;
	}
}
//	import scanner
import java.util.Scanner;

public class BoxOfficeRunner {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		System.out.println("Please enter your name.");
		String name = scan.next();
		
		System.out.println("Please enter a letter for location: \n (B)ox \n (L)awn \n (P)avilion");
		String location = scan.next();
		
		//	prompt for number of tickets
		System.out.println("Please enter number of tickets you need.");
		int tix = scan.nextInt();		
		
		//	send data over to BoxOffice class
		BoxOffice boxOffice = new BoxOffice();
		boxOffice.getName(name);
		boxOffice.getLocation(location);
		boxOffice.getNumTix(tix);
		
		//	SOP Message		(Kevin, thank you for purchasing 3 Lawn tickets)
		System.out.println(boxOffice.sendMessage());
		//	SOP	Subtotal	(Subtotal:  $ 150.00)
		System.out.println("Subtotal: $" + boxOffice.calcSubtotal());
		//	SOP SalesTax		(Sales Tax:  $ 9.00)
		System.out.println("Sales Tax: $" + boxOffice.calcSalesTax());
		//	SOP Total		(Total:  $ 159.00)
		System.out.println("Total: $" + boxOffice.calcTotal());
	}

}