cal516
2015-03-17 14:43:27
All, I am new to this forum and I am hoping I came to the right spot…. I am having trouble with this simple program. What I am attempting to do is simply work with dialog boxes and user inputs. My end state for this current segment is to simply have this output happen when I run the program:
Dialog Box: Enter the customer's package (A, B, or C);
User input: A
Dialog Box: Enter the hours used:
Any overages in hours need to be added as additional charges. For example Package A has a maximum of 10 hours access. Additional hours are $2.00 per hour. So if a user input 11 hours for Package his total would be $11.95. It needs to be adjustable of course with user input for hours. I am not sure how to do this? Any input would be greatly appreciated.
Dialog Box/Message: The charges are "total with hours input."
Thank you in advance
Dialog Box: Enter the customer's package (A, B, or C);
User input: A
Dialog Box: Enter the hours used:
Any overages in hours need to be added as additional charges. For example Package A has a maximum of 10 hours access. Additional hours are $2.00 per hour. So if a user input 11 hours for Package his total would be $11.95. It needs to be adjustable of course with user input for hours. I am not sure how to do this? Any input would be greatly appreciated.
Dialog Box/Message: The charges are "total with hours input."
Thank you in advance
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
public class ColapietroPass4Draft
{
public static void main(String[] args)
{
char packageSelect;
final double Package_A = 9.95,
Package_B = 13.95,
Package_C = 19.95,
Package_A_Hours = 10,
Package_B_Hours = 20;
double hoursSelect;
String input = JOptionPane.showInputDialog("Enter customer's package (A,B or C):");
System.out.println();
packageSelect = input.charAt(0);
String hours = JOptionPane.showInputDialog("Enter the number of hours used):");
if (packageSelect == 'A')
{
JOptionPane.showMessageDialog(null, "The charges are " + Package_A);
}
if (packageSelect == 'B')
{
JOptionPane.showMessageDialog(null, "The charges are " + Package_B);
}
if (packageSelect == 'C')
{
JOptionPane.showMessageDialog(null, "The charges are " + Package_C);
}
System.exit(0);
}
}