View the step-by-step solution to:



Please follow the instructions and guidelines in the both files attached. Make sure the

code is internally documented.

Asst. 3 : Make me a sandwich! 1 Preparation You are expected to be familiar with the following textbook sections and lectures before coming to the lab. You are also recommended to complete the exercises below before starting to code. Bring the answers to the lab, if you would like feedback before coding your solution. This assignment involves invoking methods. There will be a brief explanation of this process during the lab. We will learn more about it soon. Textbook sections 3.1 - 3.5, 3.13 Most relevant lectures L5, L6 Exercises 1. Read through the entire assignment, to get a good understanding of the problem you need to solve. 2. Write a full algorithm to solve the Sandwich problem. Do not hand-write Java code. The algorithm should have: input(s) – including requirements and names for the inputs a list of variables numbered, precise steps output(s) 2 The sandwich problem You will create an algorithm and a program to solve the following problem. A customer would like to order a sandwich. They will select various options, and the program will then remind them what type and size of sandwich they ordered, as well as displaying a price for the sandwich. Types: There are four types of sandwich. Three are standard sandwich choices, or the customer can create a custom sandwich. Sizes: There are three sizes, with different base prices. Half-size costs $4.00, full-size costs $6.50, and overstuffed costs $8.00. Bread and sauce: Custom (build your own) sandwiches have the option to upgrade bread or sauce. Special artisan bread costs an additional $1.00. Extra sauce costs an additional $0.50. Toppings: Only when building a custom sandwich: There are eight regular toppings to choose from. The customer may select 3 of these at no charge, and then each additional regular topping costs $0.50. There are ±ve premium toppings to choose from. The customer may 1
Background image of page 1
Asst. 3 : Make me a sandwich! select 1 of these at no charge, and then each additional premium topping costs $1.50. (You do not need to keep track of which toppings the customer wants. Only the number of regular and premium toppings is important.) 2.1 Specifcations Write a program to solve the above problem. User input: When prompting the user for input, you are required to use one of the provided print methods, de±ned by the instructor in . You are only permitted to scan in integer types from the user. Output: Your program must print the correct price in dollars of the desired sandwich, as well as the name of the sandwich. This means the name of the type of sandwich ordered, and the name of the selected size. If a custom sandwich is ordered, you do not need to print out selected toppings and upgrades. Sample console (standard sandwich) when the program has terminated. Note that if the user selects “Build your own” (custom sandwich), they need to also be prompted to select regular and premium toppings, and they must be asked if they would like to upgrade their sauce or bread. MENU: (Please select one of the following numerical options .) 1 Chicken Parmesan 2 Turkey Pesto 3 Breakfast Sandwich 4 Build your own 2 SIZE: (Please select a size.) 1 Half -size , $4.00 2 Full -size , $6.50 3 Overstuffed , $8.00 1 You have ordered a half -size turkey pesto sandwich. Please pay $4.00. 2.2 Instructions 1. Compare your algorithm with your partner’s. Discuss if you will merge the two algorithms, taking components from each, or if you will simply choose to follow one partner’s algorithm. 2. Download the ±le from D2L. Open this ±le in SciTE. 3. Modify the ±le header to include identifying information as required by the Lab Guide . 2
Background image of page 2
Show entire document
// IMPORT STATEMENT(S) HERE /* * Header: Should include all standard biographical information. * * Description of your program always goes here, including inputs, outputs, and general behaviour * */ public class Sandwich{ public static void main(String[] args){ // DECLARE ALL REQUIRED VARIABLES HERE: // TRANSLATE YOUR ALGORITHM INTO CODE HERE: /* The following statements invoke some * printing methods defined below the main method. * YOU WILL NEED TO MOVE THESE METHOD CALLS * TO APPROPRIATE SPOTS IN YOUR OWN CODE. * Try commenting out all but one, and see what * happens when you run this program. */ printMenu(); printSizes(); printRegToppings(); printPremToppings(); printSauce(); printBread(); } // end main public static void printMenu(){ System.out.print("MENU: \n(Please select one of the following numerical options.)\n"); System.out.print("1 Chicken Parmesan \n2 Turkey Pesto\n3 Breakfast Sandwich\n" + "4 Build your own\n"); } // end printMenu public static void printSizes(){ System.out.print("\nSIZE:\n(Please select a size.)\n1 Half-size, $4.00\n2 Full-size, " + "$6.50\n3 Overstuffed, $8.00\n"); } // end printSizes public static void printRegToppings(){ System.out.print("\nREGULAR TOPPINGS:\nThe regular toppings are:\nTomato, Sprouts, " + "Mushroom, Cheddar, Red onion, Spinach, Jalapenos, Mozzarella\n\n" + "How many of these would you like?\n(Three are included and then " + "each additional regular topping costs $0.50.)\n"); } // end printRegToppings public static void printPremToppings(){ System.out.print("\nPREMIUM TOPPINGS:\nThe premium toppings are:\nChicken, Turkey, " + "Egg, Goat cheese, Grilled eggplant\n\n" + "How many of these would you like?\n(One is included and then " + " each additional premium topping costs $1.50.)\n");
Background image of page 1
} // end printPremToppings public static void printSauce(){ System.out.print("\nEXTRA SAUCE?:\nYour choice of sauce is included.\n" + "1 Add extra sauce, $0.50 \n2 Regular amount of sauce\n"); } // end printSauce public static void printBread(){ System.out.print("\nARTISAN BREAD?:\nYour choice of white, whole wheat, or rye bread is included.\n" + "1 Upgrade to artisan bread, $1.00 \n2 Regular bread\n"); } // end printBread } // end class
Background image of page 2
Sign up to view the entire interaction

Top Answer

View the full answer - Preview not available

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online