Element17
2013-09-25 15:01:34
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 unlimited access is provided.
Write a program that calculates a customer’s monthly bill. It should ask the user via a dialog box to enter the letter of the package the customer has purchases (A, B, C) and the number of hours that were used. It should then display the total charge in a dialog box.
How do I make it so I can use A, B or C instead of 1, 2, 3?
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 unlimited access is provided.
Write a program that calculates a customer’s monthly bill. It should ask the user via a dialog box to enter the letter of the package the customer has purchases (A, B, C) and the number of hours that were used. It should then display the total charge in a dialog box.
How do I make it so I can use A, B or C instead of 1, 2, 3?
import javax.swing.JOptionPane;
/*Andrew Varnick
9/23/2013
CSCI 1015
Programming Assignment 4
A program to calculate a monthly bill
*/
public class VarnickPass4
{
//Constants
static final double PackA = 9.95;
static final double PackB = 13.95;
static final double PackC = 19.95;
public static void main(String[] args)
{
String input;
String numberOfHoursUsed;
int numberOfHours;
int packageInput;
double finalPrice;
double PackA = 9.95;
double PackB = 13.95;
double PackC = 19.95;
input = JOptionPane.showInputDialog("Which package do you have?(A = 1, B = 2 or C= 3)");
packageInput = Integer.parseInt(input);
if (packageInput == 1)
{
numberOfHoursUsed = JOptionPane.showInputDialog("How many hours have you used this month?");
numberOfHours = Integer.parseInt(numberOfHoursUsed);
finalPrice = ((numberOfHours - 10) * 2 + PackA);
JOptionPane.showMessageDialog(null, "The final price is $" + finalPrice);
}
else
{
if (packageInput == 2)
{
numberOfHoursUsed = JOptionPane.showInputDialog("How many hours have you used this month?");
numberOfHours = Integer.parseInt(numberOfHoursUsed);
finalPrice = ((numberOfHours - 20) * 1 + PackB);
JOptionPane.showMessageDialog(null, "The final price is $" + finalPrice);
}
else
{
if (packageInput == 3)
numberOfHoursUsed = JOptionPane.showInputDialog("You have unlimated access!");
finalPrice = (PackC);
JOptionPane.showMessageDialog(null, "The final price is $" + finalPrice);
}
}
}
}