Académique Documents
Professionnel Documents
Culture Documents
DecimalFormat;
import java.util.Scanner;
// Variables
String firstName; // first name of user
char crustType;
String crust; // name of crust
int inches; // pizza size
double cost = 0.0; // pizza cost
final double taxRate = 0.08; // amount tax owed
double tax; // tax amount
double total; // total of pizza + toppings
double lastTotal; // total of everything
int numberOfToppings = 0;
int numberOfToppings2 =0;
int numberOfToppings3;
String toppings = "Cheese";
// Pepperoni
System.out.println("Do you want Pepperoni? (Y/N)" );
numberOfToppings = keyboard.nextLine().charAt(0);
if (numberOfToppings == 'Y' || numberOfToppings == 'y' ){
numberOfToppings = 1;
toppings = toppings + " and Pepperoni";}
else{
numberOfToppings = 0;
}
//Sausage
System.out.println("Do you want Sausage? (Y/N)" );
numberOfToppings2 = keyboard.nextLine().charAt(0);
if (numberOfToppings2 == 'Y' || numberOfToppings2 == 'y' ){
numberOfToppings2 = 1;
toppings = toppings + " and Sausage";}
else{
numberOfToppings2 = 0;}
// Calculations
total = (cost) + (numberOfToppings3 * 1.25) + (deliveryfee);
tax = total * taxRate;
lastTotal = total * ( 1 + taxRate );
// Payment Confirmation
System.out.println(firstName + ", here is your order:");
System.out.println(inches + " inch pizza");
System.out.println(crust +", " + toppings);
System.out.println("Order Cost: $" + df.format(total));
System.out.println("Tax: $" + df.format(tax));
System.out.println("Total Due: $" + df.format(lastTotal));
}