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....
Please make the following code modular. Therefore contained in a package with several classes and not just one. import java.util.*; public class Q { public static LinkedList<String> dogs = new LinkedList<String> (); public static LinkedList<String> cats = new LinkedList<String> (); public static LinkedList<String> animals = new LinkedList<String> (); public static void enqueueCats(){ System.out.println("Enter name"); Scanner sc=new Scanner(System.in); String name = sc.next(); cats.addLast(name); animals.addLast(name); } ...
My Question is: I have to modify this program, even a small modification is fine. Can anyone give any suggestion and solution? Thanks in Advanced. import java.util.*; class arrayQueue { protected int Queue[]; protected int front, rear, size, len; public arrayQueue(int n) { size = n; len = 0; Queue = new int[size]; front = -1; rear = -1; } public boolean isEmpty() { return front == -1; } public boolean isFull() { return front == 0 && rear ==size...
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 =...
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 = ""; ...
Please help me edit my code so it looks a little different but produces the same output. Me and classmate did the assignment correctly but are afraid of plagarism. Here is my code. /** * @(#) * @author * @version 1.00 6/25/2017 3:00 PM * Program Purpose: Code a program that computes sales revenue * to-date to determine the status of the company’s * sales revenue and whether a year end bonus is in store for the employees. */ import...
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...