Here is my code:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package internetserviceproviderpart2; import javax.swing.JOptionPane; /** * * @author Home */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { String inputString; char packageLetter; int hoursUsed; int additionalHours = 0; double totalFeeA = 0; double totalFeeB = 0; double savingsAB = 0; double savingsAC = 0; double savingsBC = 0; inputString = JOptionPane.showInputDialog("Enter the letter of the " + "package you purchased (either A, B, or C.)"); inputString = inputString.toUpperCase(); packageLetter = inputString.charAt(0); inputString = JOptionPane.showInputDialog("Enter the number of hours " + "you used."); hoursUsed = Integer.parseInt(inputString); if (packageLetter=='A' && hoursUsed>10) { additionalHours = hoursUsed - 10; totalFeeA = 9.95 + (additionalHours * 2.00); JOptionPane.showMessageDialog(null,"Your monthly bill is $" + totalFeeA); } else if (packageLetter=='A' && hoursUsed<=10) JOptionPane.showMessageDialog(null,"Your monthly bill is $9.95."); else if (packageLetter=='B' && hoursUsed>20) { additionalHours = hoursUsed - 20; totalFeeB = 13.95 + (additionalHours * 1.00); JOptionPane.showMessageDialog(null,"Your monthly bill is $" + totalFeeB); } else if (packageLetter=='B' && hoursUsed<=20) JOptionPane.showMessageDialog(null,"Your monthly bill is $13.95."); else if (packageLetter=='C') JOptionPane.showMessageDialog(null,"Your monthly bill is $19.95."); else JOptionPane.showMessageDialog(null,"Enter either A, B, or C."); if(totalFeeA>totalFeeB) { savingsAB = totalFeeA - totalFeeB; JOptionPane.showMessageDialog(null,"You would save $" + savingsAB + "if you purchase Package B."); } else if (totalFeeA>19.95) { savingsAC = totalFeeA - 19.95; JOptionPane.showMessageDialog(null,"You would save $" + savingsAC + "if you purchase Package C."); } else if (totalFeeB>19.95) { savingsBC = totalFeeB - 19.95; JOptionPane.showMessageDialog(null,"You would save $" + savingsBC + "if you purchase Package C."); } else System.exit(0); } }
Next to
public class Main {
there is a red circle with an exclamation point inside saying "class Main is public, should be declared in a file named Main.java"
I'm not too sure what that means.
Also, when I run the program...this pops out:
run: java.lang.ExceptionInInitializerError Caused by: java.lang.RuntimeException: Uncompilable source code - class Main is public, should be declared in a file named Main.java at internetserviceprovider.Main.<clinit>(Internet Service Provider.java:12) Could not find the main class: internetserviceprovider.Main. Program will exit. Exception in thread "main" Exception in thread "main" Java Result: 1 BUILD SUCCESSFUL (total time: 2 seconds)
How do I fix it so I can run the program correctly?