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: 70'' Smart TV + Pixel 9+ MacBook Pro
Package Gold: Pixel 9+ MacBook Pro
Package Silver: MacBook Pro
Prices:
70'' Smart TV: $599.96 Pixel 9: $699.33 MacBook Pro: $1699.57
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 #1:
>>> Labor Day Sale <<<
P: Package Platinum: 70" Smart TV & Pixel 9 & MacBook Pro
G: Package Gold: Pixel 9 & MacBook Pro
S: Package Silver: MacBook Pro
Q: Quit
Please select a package: p
Package Platinum: 70" Smart TV & Pixel 9 & MacBook Pro
Total: $2998.90
Thank you for shopping at BetterBuy!
Here is my code but still have errors starting with line 22 at "switch (input):
import java.util.Scanner;
public class LaborDaySale{
public static void main(String[] args){
double tvPrice =599.96;
double pixelPrice =699.33;
double macbookPrice =1699.57;
double totalPlatinumPrice = tvPrice + pixelPrice + macbookPrice;
double totalGoldPrice = pixelPrice + macbookPrice;
double totalSilverPrice = macbookPrice;
Scanner keyboard = new Scanner(System.in);
Scanner scanner;
while(true)//label loop
System.out.println("Labor Day Sale");
System.out.println("P: Package Platinum: 70\" Smart TV & Pixel 9 & MacBook Pro");
System.out.println("G: Package Gold: Pixel 9 & MacBook Pro");
System.out.println("S: Package Silver: MacBook Pro");
System.out.println("Q: Quit");
System.out.println("Please select an package: ");
char input = Character.toUpperCase(scanner.next().charAt(0));
Switch (input){
case 'P':
case'p':
//Calculate total price for Platinum package
System.out.println("Package Platinum: 70\" Smart TV & Pixel 9 & MacBook Pro");
System.out.println("Total: $"+totalPlatinumPrice);
break;
//Calculate total for Gold package
case 'G':
case'g':
System.out.println("Package Gold: Pixel 9 & MacBook Pro");
System.out.println("Total Price: $"+ totalGoldPrice);
break;
//Silver Package total
case 'S':
case's':
System.out.println("Package Silver: MacBook Pro");
System.out.println("Total Price: $"+ totalSilverPrice);
break;
case 'Q':
case'q':
System.out.println("Thank you for shopping at BetterBuy!");
break;
default:
System.out.println("Invalid 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 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 Programming Questions!