Question: Edit the program to get the following output import java.util.Scanner; // define our class public class BCS345hw1 { public static void main(String[] args) { //

Edit the program to get the following output

import java.util.Scanner;

// define our class

public class BCS345hw1 {

public static void main(String[] args) {

// declare all variables

char phonePlan;

String fullName;

double minutesUsed;

double totalCharges = 0;

// create keyboard for the Scanner class

Scanner keyboard = new Scanner(System.in);

// menu that will display to the user about the type of phone plan to choose from

System.out.println(" Mobile Phone Service Plan");

System.out.println("----------------------------------------------------------");

System.out.println("Plan A: $39.99 per month. 450 free minutes. Additional usage costs $0.45 per minute.");

System.out.println(" Plan B: $59.99 per month. 900 free minutes. Additional usage costs $0.40 per minute.");

System.out.println(" Plan C: $69.99 per month. Unlimited minutes. ");

// prompts the user to enter their full name

System.out.print(" Please enter your full name: ");

fullName = keyboard.nextLine();

// prompt the user to enter the package purchased

System.out.print("Which mobile service plan was purchased? (A,B, or C)? : ");

phonePlan = keyboard.next().charAt(0);

// while loop that test for data input validation

while (phonePlan != 'A' && phonePlan != 'a'

&& phonePlan != 'B' && phonePlan != 'b'

&& phonePlan != 'C' && phonePlan != 'c') {

// error message if your input doesnt match the cases for the phone plan

System.out.println(" You have entered the wrong phone plan "

+ "The package should be A or B or C only.");

phonePlan = keyboard.next().charAt(0);

}

// prompts the user to enter the amount of minutes used from last month

System.out.print("How many minutes did you use last month? :");

minutesUsed = keyboard.nextInt();

//while loop that checks user input if its negative

while (minutesUsed

//error message if minutes is negative

System.out.print("Error, minutes cant be negative :");

minutesUsed = keyboard.nextInt();

}

double plan_a, plan_b, plan_c;

if (minutesUsed

plan_a = 39.99;

} else {

plan_a = 39.99 + (0.45 * (minutesUsed - 450));

}

if (minutesUsed

plan_b = 59.99;

} else {

plan_b = 59.99 + (0.40 * (minutesUsed - 900));

}

plan_c = 69.99;

switch (phonePlan) {

case 'A':

case 'a':

// if package A was bought

totalCharges = plan_a;

break;

case 'B':

case 'b': // if package B was bought

totalCharges = plan_b;

break;

case 'C':

case 'c':

// if package C was bought

totalCharges = plan_c;

break;

default: //if an invalid package is selected

System.out.println(" You have entered wrong option for package "

+ "The package should be A or B or C only.");

} // end of the switch

System.out.println(" Monthly Statement for " + fullName);

System.out.printf("Plan " + phonePlan + " - Minutes used: " + "%.2f", minutesUsed);

System.out.printf(" The charges are: $%.2f ", totalCharges);

for (int i = 32; i

// priting characters from 32 to 126

for (int j = i; j

// printing 16 characters in one line

System.out.print((char) j + " ");

// printing character and space.

}

System.out.println();

}

}

}

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 Databases Questions!