Question
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
import java.util.Scanner;/**
*
* @author
*/
public class YoshiPizza {
/**
* global constant variables
*/
private static final double COST_PIZZA_SM = 12.75;
private static final double COST_PIZZA_LA = 18.75;
private static final double COST_SALAD_SIDES = 7.25;
private static final double COST_CAN_COLA = 1.75;
private static final double COST_PACKS_COLA = 8.00;
private static final double COST_2L_COLA = 3.75;
//private static final int
private static final String[] ITEMS = {
"Pizza", "Pizza", "Sides", "Cola", "Cola", "Cola"
};
private static final String[] SIZES = {
"Small", "Larges", "Salad", "1 can", "6-pack", "2 L"
};
private static final double[] PRICES = {
COST_PIZZA_SM, COST_PIZZA_LA, COST_SALAD_SIDES,
COST_CAN_COLA, COST_PACKS_COLA, COST_2L_COLA
};
public static void main(String[] args) {
/**
* constant variables
*
* Declare and use constants for the each of the costs of the different
* items being sold (e.g. COST_PIZZA_SM=12.75, COST_PIZZA_LG=18.75,
* etc.), GST and deposit prices. (No magic numbers!)
*/
final double COST_DEPOSIT_SM = 0.1;
final double COST_DEPOSIT_PACK = COST_DEPOSIT_SM * 6;
final double COST_DEPOSIT_LG = 0.25;
final double GST = 1.05;
final char YES = 'y';
final char PIZZA = 'p';
final char COLA = 'c';
final char SIDES = 's';
final String ONE = "one";
final String TWO = "two";
final String SIX = "six";
final char SMALL = 's';
final char LARGE = 'l';
final char EXIT = 'x';
/**
* variables
*/
Scanner scanner = new Scanner(System.in);
double total = 0;
char selection;
double cost;
double subtotal;
int number;
int numPizzaSM = 0;
int numPizzaLA = 0;
int numSide = 0;
int numColaOne = 0;
int numColaTwo = 0;
int numColaSix = 0;
int numCustomer = 0;
System.out.println(
"******************************************* \n"
+ "*** Welcome to Yoshi's Pizza Restaurant *** \n"
+ "*** Today's date is Jan-31-2020 *** \n"
+ "*******************************************");
do {
// payemnt of the current customer
subtotal = 0;
// loop until the custaomer want to stop
do {
// show menuw
printMenu();
System.out.print("Enter item choice (P - Pizza, "
+ "S - Sides, C - Cola, or X - exit): ");
// get selection
// Use a character data type for the type of purchase
// being made, i.e. the type value will be
// one of p, P, s, S, d or D.
selection = scanner.next().toLowerCase().charAt(0);
// the customer want to stop
if (selection == EXIT) {
// Use a sentinel-controlled loop – stopping when
// the user enters “x” or “X” (for Exit).
// Your program will continue until the order details
// for the final customer of the day have
// been calculated.
break;
}...