Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Look at the code below then make flowchart on t /** * @version 09/13/2017 * Description: Small cafe - allow the user to buy something
Look at the code below then make flowchart on t
/**
* @version 09/13/2017
* Description: Small cafe - allow the user to buy something from the menu
*
* Pseudocode:
* 1. Display a Cafe menu
* 2. Update price according to what the user wishes to purchase
* 3. Display a specific message according to what the customer would like to buy
* 4. Display the price to the user with tax
* 5. Say goodbye!
*/
// Import Scanner
import java.util.*;
public class Cafe{
public static void main(String[] args){
// Declare variables and Scanner
Scanner scanner = new Scanner(System.in);
int choice = 0;
double price = 0;
// Display menu
System.out.println("Welcome! What would you like to purchase? ");
System.out.println("1. Coffee");
System.out.println("2. Tea");
System.out.println("3. Cookie");
// Get the user's choice
System.out.print(" What product would you like to purchase: ");
choice = scanner.nextInt();
// Determine price and message according to user's choice
if(choice == 1){
price = 2.5;
System.out.println("Coffee is great!");
}
else if(choice == 2){
price = 1.75;
System.out.println("Sure! We'll get you some tea.");
}
else if(choice == 3){
price = 1.25;
System.out.println("Yum. Cookies!");
}
else{
System.out.println("You didn't choose anything from our menu!");
} // End If Statement
/* Print final price with taxes.
* Notice that this is a different type of print statement,
* allowing you to format the value. The %.2f means you round to
* two decimal places, and the (price * 1.07) is the value to be
* printed. */
System.out.printf("That will cost $%.2f with tax.", (price * 1.07));
System.out.println(" Goodbye!");
} // End Main Method
} // End Class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started