Modify the program below so it also calculates and displays the amount of money Package A customers would save if they purchased Package B or C, and the amount of money Package B customers would save if they purchased Package C. If there would be no savings, no message should be printed.
import java.util.*;
public class Lab2 {
public static void main (String[] args) {
//scanner
Scanner input = new Scanner(System.in);
//declarations
int hours;
char pack;
double totalCharges = 0;
//inputs
System.out.println("Enter the letter of the package purchased (A,
B, or C):");
pack = input.next().charAt(0);
System.out.println("Enter the hours worked:");
hours = input.nextInt();
//switch Statements
switch (pack) {
case 'A': {
totalCharges = 9.95;
if (hours > 10)
totalCharges += (hours - 10) * 2;
}
break;
case 'B': {
totalCharges = 13.95;
if (hours > 20)
totalCharges += (hours - 10) * 1;
}
break;
case 'C': {
totalCharges = 19.95;
}
break;
default: System.out.println("Incorrect Package...please choose A,B,
or C.");
}
System.out.printf("The monthly bill on the package " + pack + " is:
$%.2f\n", totalCharges);
}
}
import java.util.*;
public class Lab2 {
public static void main (String[] args) {
//scanner
Scanner input = new Scanner(System.in);
//declarations
int hours;
char pack;
double totalCharges = 0;
//inputs
System.out.println("Enter the letter of the package purchased (A, B, or C):");
pack = input.next().charAt(0);
System.out.println("Enter the hours worked:");
hours = input.nextInt();
//switch Statements
switch (pack) {
case 'A': {
totalCharges = 9.95;
//calculating remaining package charges
if (hours > 10)
totalCharges += (hours - 10) * 2;
double packageBCharges=13.95;
if (hours > 20)
packageBCharges += (hours - 10) * 1;
double packageCCharges = 19.95;
//as per the difference printing the messages
if(totalCharges>packageBCharges)
System.out.println("You would have saved $"+(totalCharges-packageBCharges)+" if you would have chosen packageB");
if(totalCharges>packageBCharges)
System.out.println("You would have saved $"+(totalCharges-packageCCharges)+" if you would have chosen packageC");
}
break;
case 'B': {
totalCharges = 13.95;
if (hours > 20)
totalCharges += (hours - 10) * 1;
//calculating remaining package charges
double packageACharges = 9.95;
if (hours > 10)
packageACharges += (hours - 10) * 2;
double packageCCharges = 19.95;
//as per the difference printing the messages
if(totalCharges>packageACharges)
System.out.println("You would have saved $"+(totalCharges-packageACharges)+" if you would have chosen packageA");
if(totalCharges>packageCCharges)
System.out.println("You would have saved $"+(totalCharges-packageCCharges)+" if you would have chosen packageC");
}
break;
case 'C': {
totalCharges = 19.95;
//calculating remaining package charges
double packageBCharges=13.95;
if (hours > 20)
packageBCharges += (hours - 10) * 1;
double packageACharges = 9.95;
if (hours > 10)
packageACharges += (hours - 10) * 2;
//as per the difference printing the messages
if(totalCharges>packageACharges)
System.out.println("You would have saved $"+(totalCharges-packageACharges)+" if you would have chosen packageA");
if(totalCharges>packageBCharges)
System.out.println("You would have saved $"+(totalCharges-packageBCharges)+" if you would have chosen packageB");
}
break;
default: System.out.println("Incorrect Package...please choose A,B, or C.");
}
System.out.printf("The monthly bill on the package " + pack + " is: $%.2f\n", totalCharges);
}
}
:output:

Modify the program below so it also calculates and displays the amount of money Package A...
write in java and you must use methods.... Part I Internet Service Provider An Internet service provider has three different subscription packages for its customers: Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour. Package B: For $13.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour. Package C: For $19.95 per month unlimited access is provided. Write a program that calculates a customer’s monthly bill....
This is what I have so far.
I'm getting an error on the ...
case 3: System.out.println("Enter the
rank of the card you want removed");
cards.remove();
System.out.println();
break;
--------------------------------------
package PlayingCards;
import java.util.Scanner;
public class Driver
{
public static void main(String[] args)
{
Scanner sc = new
Scanner(System.in);
boolean done = false;
int menuInput;
DeckOfCards cards = new DeckOfCards();
do
{
System.out.println("Enter the number
of one of the choices below:");
System.out.println("1: Shuffle The
Deck.");
System.out.println("2: Print The Cards
Remaining In...
Java // Topic 2c // Program reserves airline seats. import java.util.Scanner public class Plane { // checks customers in and assigns them a boarding pass // To the human user, Seats 1 to 2 are for First Class passengers and Seats 3 to 5 are for Economy Class passengers // public void reserveSeats() { int counter = 0; int section = 0; int choice = 0; String eatRest = ""; //to hold junk in input buffer String inName = ""; ...
1. Write a Java program to count all words in a string. User inputs a string sentence and your program should count the number of words in that string. Test Data: Input the string: The quick brown fox jumps over the lazy dog. Expected Output: Number of words in the string: 9 2. Write a class called ATMTransaction. This class has a variable balance and account number. It has three methods, checkBalance, deposit and withdraws along with constructors getters and...
Rewrite the following program using the DecimalFormat class so that your output looks like that below. Once again, the example is not calculated as 3/10ths of a percent. Welcome to NIU Investments! Please enter the amount you would like to invest today: 34543.25 Total Investment: $34,543.25 Service Charge: $22.33 ------------- Total Amount Due: $34,565.58 Thank you for your investment! Program: package org.students; import java.util.Scanner; public class NIUInvestments { //Declaring constant public static final double SCHARGE=0.0006464; public...
If I enter a negative value the program throws an error and the withdrawal amount is added to the balance please help me find why? public abstract class BankAccount { private double balance; private int numOfDeposits; private int numOfwithdrawals; private double apr; private double serviceCharge; //Create getter and setter methods public double getBalance() { return balance; } public void setBalance(double balance) { this.balance = balance; } public int getNumOfDeposits() { return numOfDeposits; } public void setNumOfDeposits(int numOfDeposits) { this.numOfDeposits =...
Original question: I need a program that simulates a flower pack with the traits listed below: - You must use a LinkedList for storage (not an Arrray list). - You must be able to display, add, remove, sort, filter, and analyze information from our flower pack. - The flower pack should hold flowers, weeds, fungus, and herbs. All should be a subclass of a plant class. - Each subclass shares certain qualities (ID, Name, and Color) – plant class -...
I cant get the code to work. Any help would be appreciated. Instruction.java package simmac; public class Instruction { public static final int DW = 0x0000; public static final int ADD = 0x0001; public static final int SUB = 0x0002; public static final int LDA = 0x0003; public static final int LDI = 0x0004; public static final int STR = 0x0005; public static final int BRH = 0x0006; public static final int CBR = 0x0007; public static final int HLT...
Below, you can find the description of your labwork for today. You can also find the expected output of this code in the Application Walkthrough section. You are going to improve your existing Money & Stock Trading Platform on previous week’s labwork by incorporating Collections. In previous labworks, you have used arrays for holding Customer and Item objects. For this labwork you need to use ArrayList for holding these objects. So, rather than defining Customer[] array, you need to define...
java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and short by name, course, instructor, and location. ///main public static void main(String[] args) { Scanner in = new Scanner(System.in); ArrayList<Student>students = new ArrayList<>(); int choice; while(true) { displayMenu(); choice = in.nextInt(); switch(choice) { case 1: in.nextLine(); System.out.println("Enter Student Name"); String name...