Question: I am writing code in java for the following: BetterBuy launched a Labor Day sale. It offered three levels of sale packages: Package Platinum: 7
I am writing code in java for the following:
BetterBuy launched a Labor Day sale. It offered three levels of sale packages:
Package Platinum: Smart TV Pixel MacBook Pro
Package Gold: Pixel MacBook Pro
Package Silver: MacBook Pro
Prices:
Smart TV: $ Pixel : $ MacBook Pro: $
The program prints a menu asking the user to input a package name, P or p for Platinum, G or g for Gold, and S or s for Silver. It will then print package items, total price, and a thank you message. If Quit selected, q or Q it will just print a thank you message. If the user's input is not P G S or Q the program prints an error message asking the user to input again until the user inputs a valid package option. Implement your program using a loop, switch and switch expression.
Sample run #:
Labor Day Sale
P: Package Platinum: Smart TV & Pixel & MacBook Pro
G: Package Gold: Pixel & MacBook Pro
S: Package Silver: MacBook Pro
Q: Quit
Please select a package: p
Package Platinum: Smart TV & Pixel & MacBook Pro
Total: $
Thank you for shopping at BetterBuy!
Here is my code but still have errors starting with line at "switch input:
import java.util.Scanner;
public class LaborDaySale
public static void mainString args
double tvPrice ;
double pixelPrice ;
double macbookPrice ;
double totalPlatinumPrice tvPrice pixelPrice macbookPrice;
double totalGoldPrice pixelPrice macbookPrice;
double totalSilverPrice macbookPrice;
Scanner keyboard new ScannerSystemin;
Scanner scanner;
whiletruelabel loop
System.out.printlnLabor Day Sale";
System.out.printlnP: Package Platinum: Smart TV & Pixel & MacBook Pro";
System.out.printlnG: Package Gold: Pixel & MacBook Pro";
System.out.printlnS: Package Silver: MacBook Pro";
System.out.printlnQ: Quit";
System.out.printlnPlease select an package: ;
char input Character.toUpperCasescannernextcharAt;
Switch input
case P:
case'p':
Calculate total price for Platinum package
System.out.printlnPackage Platinum: Smart TV & Pixel & MacBook Pro";
System.out.printlnTotal: $totalPlatinumPrice;
break;
Calculate total for Gold package
case G:
case'g':
System.out.printlnPackage Gold: Pixel & MacBook Pro";
System.out.printlnTotal Price: $ totalGoldPrice;
break;
Silver Package total
case S:
case's':
System.out.printlnPackage Silver: MacBook Pro";
System.out.printlnTotal Price: $ totalSilverPrice;
break;
case Q:
case'q':
System.out.printlnThank you for shopping at BetterBuy!";
break;
default:
System.out.printlnInvalid input. Please try again.";
while input Q;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
