I am writing a program for my class that asks the user for a specific type of internet package and how many hours they will spend on the internet.
I only have package A on this right now, but I will add the other packages after this error is fixed.
The error message I have is as follows:
IspTester.java:36: cannot find symbol
symbol : constructor InternetAccount()
location : class InternetAccount
InternetAccount pack = new InternetAccount();
thank you very much for your future help!
This is the program that has the error.
import java.util.Scanner; public class IspTester { public static void main(String[] args) { //Naming variables double hours; String packageType; //Create a Scanner object to read from the keyboard Scanner keyboard = new Scanner(System.in); //Ask for hours used and package type System.out.print("Enter the hours used and the package type: "); hours = keyboard.nextDouble(); packageType = keyboard.nextLine().trim(); //Declare and instantiiate an object reference variable InternetAccount pack = new InternetAccount(); //Set the package type based on the user input if (packageType.equalsIgnoreCase("A")) { pack.setCostOfA(hours); } else { pack.setCostOfA(hours); } } }
and this is the other program that has the setter and getter methods and such.
public class InternetAccount { //Naming variables private double monthlyHours, subType, subAHours, subBHours, subCHours; private double subA, subB, subC; //Constructor public InternetAccount(double m, double s) { monthlyHours = m; subType = s; } //Get hours used for month public double getHours() { return monthlyHours; } //Set hours used for month public void setHours(double m) { monthlyHours = m; } //Set and calculate hours for package A public void setCostOfA(double hours) { subAHours = hours - 10; subA = (subAHours * 1.99) + 9.95; } //Get Cost of Package A public double getCostOfA() { return subA; } }
Once again, thank you for the help!