Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do I change this, I need to use switch statements import java.io.*; import j

ID: 3764691 • Letter: H

Question

How do I change this, I need to use switch statements

import java.io.*;

import java.util.Scanner;

import java.text.DecimalFormat;

class InternetProviderPart2

{

public static void main(String[] args)

{

int hours; double packageA_amount,

packageB_amount,

packageC_amount;

double total_amount=0;

DecimalFormat formatter = new DecimalFormat(" 0.00");

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter hours:");

hours=keyboard.nextInt();

if(hours<10)

packageA_amount=9.95;

else

packageA_amount=9.95+((hours-10)*2);

if(hours<20) packageB_amount=14.95;

else

packageB_amount=14.95+((hours-20)*1);

packageC_amount=19.95;

double difference;

difference=packageA_amount- packageB_amount;

System.out.println("Package A customer would save $"

+formatter.format(difference)+ " than Package B");

difference=packageA_amount - packageC_amount;

System.out.println("Package A customer would save $"

+formatter.format(difference)+ " than Package C");

difference=packageB_amount - packageC_amount;

System.out.println("Package B customer would save $" +formatter.format(difference)+ " than Package C"); System.exit(0);

}

}

Explanation / Answer

import java.util.Scanner; public class InternetPackages { public static void main(String [] args) { String input; //hold a line of input char Package; //hold single character int hours; //holds hour online double baseA = 9.95; double baseB = 13.95; double baseC = 19.95; //Scanner to read input from user Scanner keyboard = new Scanner(System.in); System.out.println("Please enter your current Package Plan: " +"A " +"B " +"C "); { input = keyboard.nextLine(); //get a line of input Package = input.charAt(0); //get the first character //ring choice = input.next(); System.out.println("How many whole hours did you use the internet for this month? " + "(Round up to the nearest whole hour.) " + "If hours exceed 30, please enter 30."); hours = keyboard.nextInt(); if (input.equals ("A")&&(hours > 10.0)) { double resultA = ((hours - 10.0) * 2)+(baseA); //first 10 hours free System.out.println("Amount due: " +resultA); } if (input.equals ("A") && (hours 20.0)) { double resultB = ((hours - 20.0) * 1)+ (baseB); System.out.println("Amount due: " +resultB); } if (input.equals ("B") && (hours
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote