Im very new to programming in general. I am taking JAVA 1 in college now. And my current assignment is to write a program that calculates a users total for a Internet Service Provider, depending on what type of package they choose. On package A, they are supposed to be billed $2 for every hours after 10 hours of internet use. on Package B, they are supposed to be billed $1 for every hours after 20 hours of internet use. I am having trouble on how to add that $2 for every hour over 10 hours of internet use in my code. Can someone help me?
Here is what I have so far. You will see the packages available in the code.
/** @ Author Brock Shelton * Date Created: February 17, 2010 * Purpose: This program wll calculate the customers monthly bill * for an Internet Service Provider. */ import javax.swing.JOptionPane; import java.text.DecimalFormat; public class InternetService2 { // begins the class /** * * @ param the args default argument for the main method * */ public static void main(String[] args) { //Declare// String welcome = "Author: Brock Shelton \n" + "Date Created: February 17, 2010 \n" + "Purpose: This program wll calculate the customers monthly bill" + "for an Internet Service Provider."; // declares a string 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."; // declares a string String input1; // declares a string String input2; //declares a string String message1 = "Please enter the letter of your package"; // declares a string String message2 = "Please enter the number of hours you used the internet"; // declares a string double a = 9.95; // declares a double double b = 13.95; // declares a double double c = 19.95; // declares a double int hours; // declares an integer String invalid = "Invalid input"; // declares a string char packages2; // declares different types of packages String total = "Your total is: $"; // declares a string // creates a DecimalFormat object DecimalFormat formatter = new DecimalFormat("#0.00"); JOptionPane.showMessageDialog(null, welcome); // ouputs a welcome message JOptionPane.showMessageDialog(null, packages); // outsputs a welcome message // INPUT// input1 = JOptionPane.showInputDialog(message1); // asks the user for the letter of the package packages2 = input1.charAt(0); // declares packages2 as a character input2 = JOptionPane.showInputDialog(message2); hours = Integer.parseInt(input2); // Process switch(packages2) { // begins the switch statement case 'a': case 'A': JOptionPane.showMessageDialog(null, total + a); // outputs the total break; // tells the program when to stop case 'b': case 'B': JOptionPane.showMessageDialog(null, total + b); break; // tells the program when to stop case 'c': case 'C': JOptionPane.showMessageDialog(null, total + c); break; // tells the program when to stop default: // if none of the cases exist, this will exicute JOptionPane.showMessageDialog(null, invalid); // outputs a message to the user } // ends the switch statement System.exit(0); // ends the program } // ends the main method } // ends the class