PLEASE SOMEONE HELP ME! I need help calculating the charges and setup to display savings.
1. Help with calculations. No matter the numbers i input just the base rate comes up.
2. I need help changing the code to "Modify the program so it calculates and displays the amount of money Packaage A customers would save if they purchased Packages 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" Any input would be great!!! Thank you ! Here's what the program looks like so far...
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
public class InternetService
{
public static void main(String[] args)
{
String packages = "Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour. \n"
+ "Package B: For $13.95 per month 20 hours of access are provided."
+ " Additional hours are $1.00 per hour.\n"
+ "Package C: For $19.95 per month unlimited access is Provided.";
String input1;
String input2;
String message1 = "Please enter the letter of your package";
String message2 = "Please enter the number of hours you used the internet";
double a = 9.95;
double b = 13.95;
double c = 19.95;
int hours;String invalid = "Invalid input";
char packages2;
String total = "Your total is: $";
DecimalFormat formatter = new DecimalFormat("#0.00");
JOptionPane.showMessageDialog(null, packages);
input1 = JOptionPane.showInputDialog(message1);
packages2 = input1.charAt(0);
input2 = JOptionPane.showInputDialog(message2);
hours = Integer.parseInt(input2);
switch(packages2)
{
case 'a':
case 'A':
JOptionPane.showMessageDialog(null, total + a);
break;
case 'b':
case 'B':
JOptionPane.showMessageDialog(null, total + b);
break;
case 'c':
case 'C':
JOptionPane.showMessageDialog(null, total + c);
break;
default: JOptionPane.showMessageDialog(null, invalid);
}
System.exit(0);
}
}
1 answer
Modify the program so it calculates and displays the amount of money Packaage A customers would save if they purchased Packages 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