Question: You are asked to develop a program for Brownie Bakery that will calculate the total price of the brownie that needs to be paid by

You are asked to develop a program for Brownie Bakery that will calculate the total price of the brownie that needs to be paid by the customer. The price of the brownie depends on the size of it as follows:

Size

Price (RM)

1 slice

First 2 numbers of your matric

Half cake

First and last number of your matric

Whole cake

((First and last number of your matric) * 2) - 2

First, the program will display your name and matric number. Declare and assign your name and matric number as constants called MY_NAME and MY_ID. Also, declare and assign the price of the brownie as constants called ONE_SLICE, HALF_CAKE, WHOLE_CAKE. As stated in the table above, the price of the brownie is based on your matric number.

For example, if my matric number is 234567, the price of the brownie will be:

1 slice RM2.30

Half cake RM27.00

Whole cake RM52.00

The program will display a menu to enable the user to choose the size. Assume that the user will never enter an invalid size (other than a, b or c). Use switch-case for ‘a’, ‘b’ and ‘c’ case. Calculate the price of the brownie based on all the input.

If the user bought half a cake, prompt a message to ask if the user wants an extra chocolate sauce. If the user wants the extra chocolate sauce, the user will be charged RM0.50.

If the user bought a whole cake, the user has the option to add a message on the brownie at an extra RM1.50. The user will be asked if they want caramel or chocolate sauce for free.

At the end, the program will display the order, total, prompt for the amount tendered and calculate the balance. All of the amounts displayed in this program must be formatted to two decimal points. You can refer to the incomplete code as the guide to writing this program.

GUIDE CODE:

import java.util.Scanner;
public class BrownieBakery {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
char size;
String option;
double price = 0;
String message = "";
String sauce = "";
double amount;
double balance;

//constants


System.out.println("Hi! I'm " + MY_NAME + " (" + MY_ID + ")");
System.out.println("Welcome to BROWNIE BAKERY");

//display size and price


System.out.println("May I take your order?");
System.out.println("---------------------");

System.out.print("Which brownie size? ");

//prompt user to enter size


//switch-case based on the size & calculate price
switch
//first case

//second case
System.out.print("Do you need extra chocolate sauce? (yes/no) ");

//prompt user to enter option


//if-else based on the option and calculate price




//third case
System.out.print("Do you want to add a message on the cake? (yes/no) ");

//prompt user to enter option


//if-else based on the option
//prompt user to enter the message
//calculate price



System.out.print("Choose your free extra sauce, caramel or chocolate? ");

//prompt user to enter sauce choice

} //end switch-case

System.out.println("BILL");
System.out.println("--------------");
System.out.println("Confirm your brownie order");

//display size


//if-else to display messages depending on the size



//display total price


System.out.print("Enter tendered amount: RM");

//prompt user to enter the amount


//calculate the balance to be returned


//display the balance
System.out.println("Thank you. Please come again");
}
}


Step by Step Solution

3.49 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The below is the java implementation code import javaio import javautil import javalang public class BrownieBakery slieOrder method public static void sliceOrderScanner sc displays the bill to the use... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!