Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have been given the task of creating a cash register program for a sandwich

ID: 3563667 • Letter: Y

Question

You have been given the task of creating a cash register program for a sandwich shop. The shop has 4 types of sandwiches. Turkey, Ham, Tuna, Roast Beef, Vegetable. You may add cheese, either American, Swiss, Provolone or cheddar. Of course you can have Lettuce, tomato and/or onion. In addition you may have   Mayo, mustard, horseradish, or Thousand Island dressing. You may have your sandwich on White, Wheat, rye, hard roll or a bagel

Price for each sandwich is:

Turkey                  6.00
Ham                       5.00
Tuna                      5.00
Roast Beef          7.00
Vegetable           6.00

Cheese                1.50 xtra

Roll                         0.50 xtra
Bagel                     1.00 xtra

Lettuce                 0.0
tomato                 0.75 xtra
Onion                    0.25 xtra

Condiments       0.0

Add 1.50 for delivery

Double meat addition 25% of the dollar amount of the sandwich ie Turkey add 1.50

Write a program to tell the customer the price of their sandwich and display a string telling what they ordered. You may use a scanner class or joption or a combination of the two.

Explanation / Answer

import java.io.DataInputStream;
import java.io.IOException;


public class Sandwich {
   static double Turkey =6, Ham=5, Tuna=5 , RoastBeef=7, Vegetable=6;
   static double cheese = 1.5 , roll = 0.50, bagel = 1.00;
   static double Lettuce = 0.0, tomato = 0.75,onion = 0.25;
   static String str = "You have ordered ";
   public static void main(String[] args) throws IOException {
       System.out.println("Please select your sandwich:");
       DataInputStream di = new DataInputStream(System.in);
       System.out.println("1.Turkey 2.Ham 3.Tuna 4.RoastBeef 5.Vegetable:");
       int d = Integer.parseInt(di.readLine());
       int tot = 0;
       switch(d){
       case 1:
           tot += Turkey;
           tot+= (Turkey * 25)/100;
           str+="Turkey";
           break;
       case 2:
           tot += Ham;
           tot+= (Ham * 25)/100;
           str+="Ham";
           break;
       case 3:
           tot+=Tuna;
           tot+= (Tuna * 25)/100;
           str+="Tune";
           break;
       case 4:
           tot+=RoastBeef;
           tot+= (RoastBeef * 25)/100;
           str+="Roast Beef";
           break;
       case 5:
           tot+=Vegetable;
           tot+= (Vegetable * 25)/100;
           break;
       }
       System.out.println("1.Add cheese 2.Don't Add:");
       d = Integer.parseInt(di.readLine());
       switch(d){
       case 1:
           tot+= cheese;
           str+=", With Cheese";
           break;
           default:
               str+=", Without cheese";
               break;
       }
       System.out.println("Want to have: 1.Lettuce 2.Tomato 3.Onion");
       d= Integer.parseInt(di.readLine());
       switch(d){
       case 1:
           tot+= Lettuce;
           str+=",With Lettuce";
           break;
       case 2:
           tot+= tomato;
           str+=",With tomato";
           break;
       case 3:
           tot+= onion;
           str+=",With onion";
           break;
       }
       System.out.println("Want to have: 1.Hard Roll 2.Bagel");
       d= Integer.parseInt(di.readLine());
       switch(d){
       case 1:
           tot+= roll;
           str+="and With roll";
           break;
       case 2:
           tot+= bagel;
           str+="and With bagel";
           break;
       }
      
       tot += 1.50;
      
       System.out.println("Total price is:"+tot);
       System.out.println(str);
   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote