Question: In java basic code only! This is my program I have written so far. Only using scanner class and basic java. I need to use
In java basic code only! This is my program I have written so far. Only using scanner class and basic java. I need to use switch and if statements like I did. It is not displaying the total bill calculations correctly or doing the part 2 of the problem at all . Can someone fix my code so it works and compiles 100% correct. Dont add advanced code just use what I have thanks!
import java.util.*Scanner;
public class InternetServiceProvider 2
{
public static void main(String[] args)
{
String userInput;
char packageChosen;
double packageA,packageB,totalHours, totalSavingsAtoB, totalSavingsAtoC, totalSavingsBtoC;
totalSavingsAtoB = (packageA - 13.95);
totalSavingsAtoC = (packageA - 19.95);
totalSavingsBtoC = (packageB - 19.95);
Scanner keyboard = new Scanner(System.in);
System.out.println("Which package have you obtain? (Please use A, B, or C)");
userInput = keyboard.nextLine();
packageChosen = userInput.charAt(0);
switch (packageChosen)
{
case 'A':
System.out.println("What are the total amount of hours used for this month?");
totalHours = keyboard.nextDouble();
if (totalHours
{
packageA = 9.95 * totalHours;
System.out.print("For Package A: The total charges for this month is $ " + packageA);
System.out.print(" You save a total of " + totalSavingsAtoB + "if you chose Package B "
+ "and you would have save a total of " + totalSavingsAtoC + "if you chose Package C.");
}
else
packageA = 9.95 + (totalHours * 2.00);
System.out.print("For Package A: The total charges for this month is $ " + packageA);
if (totalSavingsAtoB > packageA)
{
totalSavingsAtoB = (packageA - 13.95);
totalSavingsAtoC = (packageA - 19.95);
System.out.print(" You save a total of " + totalSavingsAtoB + "if you chose Package B "
+ "and you would have save a total of " + totalSavingsAtoC + "if you chose Package C.");
}
break;
case 'B':
System.out.println("What are the total amount of hours used for this month?");
totalHours = keyboard.nextDouble();
if (totalHours
13. 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 Package B: For $13.95 per month 20 hours of access are provided. Additional hours Package C: For $19.95 per month unlimited access is provided. Write a program that calculates a customer's monthly bill. It should ask the user to enter are $2.00 per hour. are $1.00 per hour. the letter of the package the customer has purchased (A, B, or C) and the number of hours that were used. It should then display the total chariges. 14. Internet Service Provider, Part 2 Modify the program you wrote for Programming Challenge 13 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 Pack- age C. If there would be no savings, no message should be printed {
packageB = 13.95 * totalHours;
System.out.print("For Package B: The total charges for this month is $" + packageB);
System.out.print("You would have save a total of " + totalSavingsBtoC + ", if you have chosen Package C.");
}
else
{
packageB = 13.95 + (totalHours * 1.00);
System.out.print("For Package B: The total charges for this month is $" + packageB);
System.out.print("You would have save a total of " + totalSavingsBtoC + ", if you have chosen Package C.");
}
if (totalSavingsAtoB > packageA)
{
totalSavingsBtoC = (packageB - 19.95);
System.out.print(" You save a total of " + totalSavingsAtoB + "if you chose Package B "
+ "and you would have save a total of " + totalSavingsAtoC + "if you chose Package C.");
}
break;
case 'C':
System.out.print("For Package C: The total charge for this is $19.95.");
System.out.print(" Thank you for using our service! " );
break;
default:
System.out.print("Invalid entry, Please try again.");
}
}
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
