Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Project Management A Systems Approach to Planning Scheduling and Controlling

Authors: Harold Kerzner

10th Edition

978-047027870, 978-0-470-5038, 470278706, 978-0470278703

More Books

Students also viewed these Accounting questions

Question

Differentiate 3sin(9x+2x)

Answered: 1 week ago

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago