i'm writing code for employee, manager, hourly worker for a class assignment but i've hit a problem that i can't figure out, the following is my code for employee followed by hourly worker. the problem is hourly worker won't compile, it's giving a "cannot find symbol constructor employee" error when i try to compile (employee class compiiles without issue. any suggestions please? i think i've been staring at it for so long i can no longer see the problem! thanks. pieter.
EMPLOYEE CLASS -
public class Employee
{
public String firstName;
public String lastName;
public double hourlyRate;
final static double NORMAL_WORKWEEK = 37.5;
public Employee(String firstName, String lastName, double hourlyRate)
{
setFirstName(firstName);
setLastName(lastName);
setHourlyRate(hourlyRate);
}
//Accessor and Mutator Methods for the employee's first name.
public String getFirstName()
{
return firstName;
}
public void setFirstName(String firstName)
{
firstName = firstName;
}
//Accessor and Mutator Methods for the employee's last name.
public String getLastName()
{
return lastName;
}
public void setLastName(String lastName)
{
lastName = lastName;
}
//Access and Mutator Methods for the employee's hourly rate.
public double getHourlyRate()
{
return hourlyRate;
}
public void setHourlyRate(double hourlyRate)
{
//If the user input is valid, update the employee's hour rate with the newly input value.
if(hourlyRate > 0)
{
hourlyRate = hourlyRate;
}
//Otherwise prevent an hour rate greater than zero being overwritten
else if(hourlyRate <=0)
{
if(hourlyRate <= 0)
{
hourlyRate = 0;
}
decorateConsole();
//Alert the user to their mistake.
System.out.println("Error ! ! ! - An attempt to set the employee " + this.firstName + " " + this.lastName + "'s hourly rate to zero was detected.\n");
decorateConsole();
}
}
public void printState()
{
decorateConsole();
System.out.println("[FIRST NAME] = " + firstName + " [LAST NAME] = " + lastName + " [HOURLY RATE] = " + hourlyRate + "\n");
decorateConsole();
}
public void decorateConsole()
{
System.out.println("+-< EMPLOYEE INFO >-------------------------------------------------------------------------------------------------------------------------+\n");
}
HOURLY WORKER CLASS -
public class HourlyWorker extends Employee
{
private double wage;
private double hours;
public HourlyWorker(String firstName, String lastName, double hourlyWage, double hoursWorked)
{
super(firstName, lastName);
this.wage = wage;
this.hours = hours;
}
public void setWage (double hourlyWage)
{
this.wage = wage;
}
public void getWage()
{
return wage;
}
public void setHours (double hours)
{
this.hours = hours;
}
public double getHours()
{
return hours;
}
}
You don't have a Employee constructor with two parameters:
super(firstName, lastName);
Try using:
super(firstName, lastName, 0.0);
EDIT as per tony request, here's a more detailed explanation.
With super(firstName, lastName); you're invoking ( trying to invoke ) a constructor in the class Employee which has two string parameters.
Reviewing the Employee class definition, we see you don't have such constructor, but you have one with three parameters:
public Employee(String firstName, String lastName, double hourlyRate)
So, the solution is to invoke that constructor instead. Since you don't have a default value for hourlyRate we can use 0.0 which is a double.
Other alternative would be to create a two parameter constructor in the Employee class
public Employee(String firstName, String lastName )
In the HourlyWorker constructor you tried to call the Employee constructor like this:
super(firstName, lastName);
but the Employee class doesn't have a constructor with two parameters. You need to pass a third parameter (hourly rate) like this:
super(firstName, lastName, 42);
In HourlyWorker you call
super(firstName, lastName);
but the Employee constructor is
Employee(String, String, double)
The signatures don't match.
EDIT: Incidentally, why does the HourlyWorker have a private wage member? How is it different (conceptually) to Employee.hourlyRate?
In your HourlyWorker class you are calling the constructor of Employee {super(firstname, lastname)} with two arguments but in Employee class you do not have any constructors that take two arguments.
You don't have a super constructor that takes only two arguments.
HourlyWorker's constructor tries to call super(firstName, lastName), but there's no such constructor declared in the parent class.
In your HourlyWorker class, you have the following line of code:
super(firstName, lastName);
But, there is no matching constructor in your employee class. Basically, the compiler is looking in your employee class for something like...
public Employee(String firstName, String lastName)
{
...
}
Define a new constructor, or call the constructor you've defined with the parameters you're missing.
You are calling HourlyEmployee's base class constructor (which is Employee's ctor) with 2 arguments instead of the 3 it wants.
Change the line in HourlyEmployee ctor from:
super(firstName, lastName);
to
super(firstName, lastName, hourlyWage);
Also, if you are still wanting to have a constructor like
public Employee(String firstName, String lastName)
{
...
}
and you know the default value from your double hourlyRate, you can try to write a new constructor like the next one:
`public Employee(String firstName, String lastName)
{
Employee(firstName, lastName, 0.0);
}`
There's something fishy going on around the else if here. It's repeated with another if and some curly braces missing. Indent your code properly and make sure the open curlys matches the closing ones.
if(hourlyRate > 0)
{
hourlyRate = hourlyRate;
}
//Otherwise prevent an hour rate greater than zero being overwritten
else if(hourlyRate <=0)
{
if(hourlyRate <= 0)
{
hourlyRate = 0;
}
decorateConsole();
Also, these kind of lines won't work as intended (you have three of them):
firstName = firstName;
It must be:
this.firstName = firstName;
Like you have in your second class.
Related
Good Morning, I've been given the assignment to:
rewrite the CommissionEmployee class as a subclass of Employee. CommissionEmployee should contain only the instance variables and methods that are not declared in superclass Employee. CommissionEmployee's constructor should invoke Employee's constructor and CommissionEmployee's toString method should invoke Employee's toString method.
Create a Driver class to test your new CommissionEmployee class. Prompt the user to input the first name, last name, social security number, gross sales, and commission rate and create a CommissionEmployee object, using the toString method to print its information.
The issue I seem to be having is class CommissionEmployeeTest will not output what I've placed in my toString method of class CommissionEmployee. I feel like like my superclass Employee is correct as well as me test class but my belief is the error lies somewhere in the method I've created to determine the earnings. The output I'm looking for is
Employees First Name Last Name
Social Security NUmber
Earnings
Earnings would be the total of gross sales + (commission rate * gross sales)
Here is what I have along with the error:
class Employee
public class Employee extends Object {
protected final String firstName;
protected final String lastName;
protected final String socialSecurityNumber;
public Employee(String firstName, String lastName, String socialSecurityNumber) {
this.firstName = firstName;
this.lastName = lastName;
this.socialSecurityNumber = socialSecurityNumber;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public String getSocialSecurityNumber() {
return socialSecurityNumber;
}
#Override
public String toString() {
return String.format(firstName, lastName, socialSecurityNumber);
}
}
class CommissionEmployee
public class CommissionEmployee extends Employee {
private double grossSales;
private double commissionRate;
private double earnings;
public CommissionEmployee(String firstName, String lastName, String socialSecurityNumber, double grossSales,
double commissionRate, double earnings) {
super(firstName, lastName, socialSecurityNumber);
if (grossSales < 0.0)
throw new IllegalArgumentException("Gross sales must be >= 0.0");
if (commissionRate <= 0.0 || commissionRate >= 1.0)
throw new IllegalArgumentException("Commission rate must be > 0.0 and < 1.0");
this.grossSales = grossSales;
this.commissionRate = commissionRate;
}
public void setGrossSales(double grossSales) {
if (grossSales < 0.0)
throw new IllegalArgumentException("Gross sales must be >= 0.0");
this.grossSales = grossSales;
}
public double getGrossSales() {
return grossSales;
}
public void setCommissionRate(double commissionRate) {
if (commissionRate <= 0.0 || commissionRate >= 1.0)
throw new IllegalArgumentException("Commission rate must be > 0.0 and < 1.0");
this.commissionRate = commissionRate;
}
public double getCommissionRate() {
return commissionRate;
}
public Double earnings(double d) {
return earnings(grossSales+ (commissionRate * grossSales));
}
public double getEarnings() {
return earnings;
}
public void setEarnings(double earnings) {
this.earnings = earnings;
}
#Override
public String toString() {
return String.format("%s: %s %s%n%s: %s%n%s: %.2f%n%s: %.2f%n%s: %.2f%n%s",
"commission employee", firstName, lastName,
"social security number", socialSecurityNumber,
"Total earnings", earnings(earnings));
}
public void setFirstName(String firstName) {
}
public void setLastName(String lastName) {
}
public void setSocialSecurityNumber(String socialSecurityNumber) {
}
public void setGrossSales(String grossSales) {
}
public void setCommissionRate(String commissionRate) {
}
}
class CommissionEmployeeTest
//CommissionEmployee test program.
import java.util.Scanner;
public class CommissionEmployeeTest {
public static void main(String[] args) { // instantiate CommissionEmployee object
CommissionEmployee employee =
new CommissionEmployee(null, null, null, 0, .1, 0);
Scanner input = new Scanner(System.in);
// get commission employee data
System.out.printf(
"Employee information obtained by get methods:%n");
System.out.printf("Enter employee's First name:");
String firstName = input.nextLine();
employee.setFirstName(firstName);
System.out.printf("Enter employee's last name:");
String lastName = input.nextLine();
employee.setLastName(lastName);
System.out.printf("Enter employee's social security number:");
String socialSecurityNumber = input.nextLine();
employee.setSocialSecurityNumber(socialSecurityNumber);
System.out.printf("Gross sales for employee:");
String grossSales = input.nextLine();
employee.setGrossSales(grossSales);
System.out.printf("Commission rate for employee:");
String commissionRate = input.nextLine();
employee.setCommissionRate(commissionRate);
System.out.printf("%n%s:%n%n%s%n",
"Updated employee information obtained by toString",
employee.toString());
}
}
Error
Employee information obtained by get methods:
Enter employee's First name:John
Enter employee's last name:Doe
Enter employee's social security number:123456789
Gross sales for employee:4000.00
Commission rate for employee:.1
Exception in thread "main" java.lang.StackOverflowError
at CommissionEmployee.earnings(CommissionEmployee.java:45)
I've tried manipulating my toString method in CommissionEmployee as well as my method to determine earnings but I feel like I'm spinning my wheels. I appreciate any help. I have 1 week left in class and feel like I can contribute more information each week when I post a question then I did the last. Thank you in advance.
I have resolved the issue. After reviewing and revising(several times) I have found my answer. I needed revision on my toString method as well as my earnings method. Cleaned up quite a bit of the code and resolved.
I want you use the method setSalary in this subclass, but I don't know how. It keeps printing out the default value which I initialized in the superclass.
Superclass code:
public abstract class Employee {
private String name;
private String ssn;
protected double salary;
public Employee (String n,String s){
this.name=n;
this.ssn=s;
this.salary=0;
}
public abstract void setSalary(double salary);
#Override
public String toString() {
return "Employee Name: " + name + ", with social security number: " + ssn;
}
}
Subclass code:*
public class HourlyEmployee extends Employee {
private int hours;
private int rate;
public HourlyEmployee(int hours, int rate, String n, String s) {
super(n, s);
this.hours = hours;
this.rate = rate;
}
public void setSalary(double salary) {
this.salary = rate*hours;
}
#Override
public String toString() {
return super.toString()+ "\n"+ "Number of working hours is " +hours+ " and the rate per hour is" + rate + "\n"+" Employee salary is: " +salary +"$";
}
}
The problem is that you are printing the value before calling the setter method. Try to call it first and then make the toString call.
At
public void setSalary(double salary) {
this.salary = rate*hours;
}
You are multiplying the default values which you set in the super class but not using the parameter.
Create the HourlyEmployee object using constructor,
Call the setSalary method on the object,
Now, toString method should return right value
In the first time, the salary property of the super class is initialized by the 0 value in the super constructor which is always called when you create the subclass instance, so you need to call setSalary method just after you created the instance of subclass to rectify the value of salary property and before you use it in the next of your code.
I have been looking around online, and I am still unsure of how to call a method in my child class. I am trying to call the pay() method in Executive, and when I type in the following code into my if statement, I keep getting an error.
staff[3].awardBonus(bonus);
I keep getting an error with this method. I'm not sure how to call that method... Thanks for any help!`import java.util.Scanner;
import java.util.Scanner;
public class Tester
{
public static void main (String args[])
{
Scanner scan = new Scanner(System.in);
StaffMember[] staff = new StaffMember[4];
String internName = "Susan 2";
String empName = "Tyler O.";
String hrName = "Becky R.";
String execName = "Daniel H.";
String address = "Brighton";
String phone = "420 - 0000";
String SSN = "12345789";
double rate = 1000;
staff [0] = new Intern(internName, address, phone);
staff [1] = new Employee(empName, address, phone, SSN, rate);
staff [2] = new HourlyEmployee(hrName, address, phone, SSN, rate);
staff [3] = new Executive(execName, address, phone, SSN, rate);
for (StaffMember staffPrint : staff)
{
System.out.println (staffPrint.toString() + "\n");
}
System.out.println("If you would like to give an executive a bonus, press 1. \nIf you would like to increase the hours of an hourly employee, press 2.");
int input = scan.nextInt();
if(input == 1)
{
double bonus = 0;
System.out.println("Enter the bonus for your employee: ");
bonus = scan.nextDouble();
}
}
Here is the Executive class, Employee class and the StaffMember class
public class Executive extends Employee
{
public Executive(String name, String address, String phone, String SSN, double rate)
{
super(name, address, phone, SSN, rate);
}
public double pay()
{
double money = super.pay();
return money;
}
public String toString()
{
String employee = super.toString();
return employee;
}
public void awardBonus(double execBonus)
{
rate += execBonus;
}
}
Employee
public class Employee extends StaffMember
{
String SSN;
double rate;
public Employee(String name, String address, String phone, String SSN, double rate)
{
super(name, address, phone);
this.SSN = SSN;
this.rate = rate;
}
public double pay()
{
return rate;
}
public String toString()
{
String employee = "";
employee = ("Name: " + name + "\nAddress: " + address + "\nPhone Number: " + phone + "\nSocial Security Number: " + SSN + "\nPay: " + pay());
return employee;
}
}
StaffMember
public abstract class StaffMember
{
String name;
String address;
String phone;
public StaffMember(String name, String address, String phone)
{
this.name = name;
this.address = address;
this.phone = phone;
}
public String toString()
{
String employee = "";
employee = ("Name: " + name + "\nAddress: " + address + "\nPhone Number: " + phone);
return employee;
}
public abstract double pay();
}
staff is a StaffMember array. When you reference any item from it (as you do it staff[3]), you get a StaffMember.
StaffMember does not have a method awardBonus().
Your problem is that you are trying to call an undefined method on your StaffMember object. In fact the method awardBonus() was not defined in your StaffMember class.
And in the code staff[3].awardBonus(bonus) you were trying to call awardBonus() on staff[3] which is a StaffMember instance.
By providing an awardBonus for all StaffMembers, you can call it on a StaffMember. For instance:
public abstract class StaffMember
{
public void awardBonus(double bonus) {
if (bonus > 0) {
throw new IllegalStateException("Only executives receive a bonus");
}
}
...
public class Executive extends StaffMember
{
#Override
public void awardBonus(double bonus) {
P.S. be careful to inform the company on this.
You can use:
// Check if staff[3] is really an Executive
if(staff[3] instanceof Executive) {
// Cast staff[3] to an Executive
Executive executive = ((Executive)staff[3]);
// Now you can call awardBonus
executive.awardBonus(bonus);
}
Because staff is an StaffMember-array which doesn't contains the methode awardBonus.
You know that staff[3] is an Executive, but your program doesn't. Therefore you have to check if staff[3] is an instanceof Executive so you can safely cast it to an Executive with Executive executive = (Executive)staff[3].
I am trying to create a constructor for class HthsStudent, where it inherits variables and states from class Student. (Student inherited variables and states from class Person.)
The problem is, java doesn't like the way I'm trying to do it, and keeps telling me that what I'm doing is wrong, even though it is exactly what I did in class Student. It tells me that there is a "invalid method declaration, return type required" error, but I don't see a way to fix it.
What am I doing wrong, and how can I fix it?
Thanks!
/**
* Write a description of class Persn here.
*
* #author (your name)
* #version (a version number or a date)
*/
public class Person
{
String firstName;
String lastName;
public Person (String firstName, String lastName)
{
this.firstName = firstName;
this.lastName = lastName;
}
public String toString ()
{
return lastName + ", " + firstName;
}
}
/**
* Write a description of class Student here.
*
* #author (your name)
* #version (a version number or a date)
*/
public class Student extends Person
{
int gradeLevel;
private static int studentId = 0;
public Student (String firstName, String lastName, int gradeLevel)
{
super(firstName, lastName);
this.gradeLevel = gradeLevel;
if (gradeLevel > 5 || gradeLevel < 0)
{
gradeLevel = 0;
}
studentId = studentId + 1;
}
public int getLevel()
{
return gradeLevel;
}
public String toString ()
{
return lastName + ", " + firstName + "\nGrade Level: " + gradeLevel + "\nID #: " + studentId;
}
}
/**
* Write a description of class HTHSStudent here.
*
* #author (your name)
* #version (a version number or a date)
*/
public class HTHSStudent extends Student
{
double gpa;
public HthsStudent (String firstName, String lastName, int gradeLevel, double gpa)
{
super(firstName, LastName, gradeLevel);
this.gpa = gpa;
if (gpa > 5.0 || gpa < 1.0)
{
gpa = 0.0;
}
}
public String toString()
{
return lastName + ", " + firstName + "\nGrade Level: " + gradeLevel + "\nID #: " + studentId + "\nGPA: " + gpa;
}
}
You're not capitalizing the last class correctly. You've got:
class HTHSStudent extends Student
{
double gpa;
public HthsStudent (String firstName, String lastName, int gradeLevel, double gpa)
It should be
class HTHSStudent extends Student
{
double gpa;
public HTHSStudent (String firstName, String lastName, int gradeLevel, double gpa)
or even better:
class HthsStudent extends Student {
private double gpa;
public HthsStudent (String firstName, String lastName, int gradeLevel, double gpa)
Note that for Java identifiers, capitalization matters
Also as noted in my comments, you've got another unrelated problem in that your studentId field should most definitely not be static. This field needs to be unique for each Student object, and if you make it static, it will become a property of the class, and thus be the same for all Students. If you made it static to fix a compiler error, then you fixed the wrong error. The correct fix is to not try to reference it in a static way, off the class.
Now i got it set as a constructor, however I am unsure how to actually use this. I want to be able to store the first name, last name and degree level. I need it to continue to run until I stop it and continue with more of the program.
import javax.swing.*;
import java.util.ArrayList;
public class Tutor
{
public Tutor(String firstName, String firstName, String degreeLevel)
{
firstName = firstName;
lastName = firstName;
degreeLevel = degreeLevel;
}
public static void main (String[] args)
{
String fName;
String lName;
String level;
String ans;
ArrayList<String> listOfTutor = new ArrayList<String>();
for (int i = 0; i<listOfTutor.size(); i++)
{
fName = JOptionPane.showInputDialog(null,"Enter Tutor's First Name: ");
lName = JOptionPane.showInputDialog(null,"Enter Tutor's Last Name: ");
level = JOptionPane.showInputDialog(null,"Enter Tutor's Highest Level of Degree: ");
Tutor t = new Tutor(fName,lName,level);
listOfTutor.add(t);
}
}
}
Edit
import javax.swing.*;
import java.util.ArrayList;
public class Tutor
{
String firstName;
String lastName;
String degreeLevel;
public Tutor(String firstName, String lastName, String degreeLevel)
{
this.firstName = firstName;
this.lastName = firstName;
this.degreeLevel = degreeLevel;
}
public static void main (String[] args)
{
String fName;
String lName;
String level;
String ans;
ArrayList<Tutor> listOfTutor = new ArrayList<Tutor>();
for (int i = 0; i<3; i++)
{
fName = JOptionPane.showInputDialog(null,"Enter Tutor's First Name: ");
lName = JOptionPane.showInputDialog(null,"Enter Tutor's Last Name: ");
level = JOptionPane.showInputDialog(null,"Enter Tutor's Highest Level of Degree: ");
Tutor t = new Tutor(fName,lName,level);
listOfTutor.add(t);
}
}
}
You need getting the error because the Tutor() function is returning a value, but no return type is given in the method declaration.
If you want your function to return a String:
public String Tutor(String firstName, String lastName, String degreeLevel)
^^^^^^
There are actually many problems in the code currently. I believe what you're trying to do is make Tutor() a constructor. If that's the case, it's declaration should be:
public CalculateATutor(String firstName, String lastName, String degreeLevel)
because CalculateATutor is the name of the class. It should not return anything. Additionally, these lines:
this.firstName = firstName;
this.lastName = lastName;
this.degreeLevel = degreeLevel;
will not work the way you want. If you're attempting to set class fields, you need to declare the fields in your class first. Like this:
public class CalculateATutor
{
String firstName;
String lastName;
String degreeLevel;
...
}
public String Tutor(String firstName, String lastName, String degreeLevel)
^ missing
as you are returning String
return(lastName +", "+ firstName +" "+ degreeLevel);
Instead our answers try to understand compiler's error message:
error: invalid method declaration; return type required
^ function declaration is wrong
Also says return type required So you forgot return type of function.
Where function name is public Tutor()
public Tutor(String firstName, String lastName, String degreeLevel)
should be
public String Tutor(String firstName, String lastName, String degreeLevel)
The error message is telling you what to do. all Java methods/functions have to be declared with a return type.
In this case it appears to be a String, so it becomes
public String Tutor()
If you dont want it to return anything then it is
public void getMiau()
Add return type to method. As you posted you are returning String without giving return type of method. So add String as return type of method.
If you try to return a value from a method that is declared void, you will get a compiler error.
public String Tutor(String firstName, String lastName, String degreeLevel) {
.....
return(lastName +", "+ firstName +" "+ degreeLevel);
}
You're treating Tutor like a method. If Tutor is indeed a method, you don't have a return type associated with it.
Also where are firstName, lastName, and degreeLevel getting declared at in the class? It looks to me like there maybe other issues than just that -- keep in mind.
Your code is really messed.
You have a class named CalculateATutor, inside it something looks like a constructor but named Tutor and you use it inside your main function as a regular class.
First, you need to understand what you want to do (and maybe read about classes and constructors).
But for your question:
If you want to have a method named Tutor, you need to add return type to the method signature;
public String Tutor(String firstName, String lastName, String degreeLevel)
{
this.firstName = firstName;
this.lastName = lastName;
this.degreeLevel = degreeLevel;
return(lastName +", "+ firstName +" "+ degreeLevel);
}
If you're trying to create a constructor, you need to use the class name and remove the return statement:
public CalculateATutor(String firstName, String lastName, String degreeLevel)
{
this.firstName = firstName;
this.lastName = lastName;
this.degreeLevel = degreeLevel;
}
You did a lot of wrong there:
First: If Tutor is a Method:
You have to set a Return Type to your Method. public static String Tutor(...)
This way your Method returns your values correctly.
Second: If Tutor should be your Class:
Then you have to rename either your class to Tutor or your Constructor to CalculateATutor.
A constructor never has a Return Type and never contains a return-Statement. So this way you have to delete your return-Statement in your Constructor.
public CalculateATutor(String firstName, String lastName, String degreeLevel)
{
this.firstName = firstName;
this.lastName = lastName;
this.degreeLevel = degreeLevel;
}
Third:
The usage of your Class Tutor (if it is a class) is wrong
String ans;
List<Tutor> myTutor = new ArrayList<Tutor>(); //You have to specify Tutor in your Template-Class
for (int i = 0; i<myTutor.size; i++)
{
ans = JOptionPane.showInputDialog(null,"Enter Tutor's Last Name, First Name, and Highest Level of Degree:");
//Here you have a lot to do because you get one inputstring with all 3 Elements
//You have to split the input or get 3 seperate inputs
// We assume you have your correct input here right now with Strings fname, lname, level
Tutor t = new Tutor(lname,fname,level);
myTutor.add(t);
}
}
EDIT:
To your new Question:
You have to declare local variables into the class.
public class TestClass{
String lastName;
public TestClass(String lastName){// this is the Constructor
this.lastName = lastName;
}
}
This way you can store the Variables.
Your Tutor method is returning a string, but you haven't declared it as having a return type. Try:
public String Tutor(String firstName, String lastName, String degreeLevel)
It's not clear if Tutor is supposed to be a method or a constructor. If it is supposed to be a constructor, you are declaring it in a class named CalculateATutor, which won't work. You also did not write the constructor as a constructor (it should not have a return statement). You can fix this in several ways:
Change the class name to Tutor.
Change the constructor name to CalculateATutor.
Move the Tutor constructor to an inner class of CalculateATutor named Tutor.
1) you're using the this. keywork to refer to class variables that you haven't defined
2) you seem to have called the class CalculateATutor but the constructor for the class Tutor, they should be the same, so something like this:
import javax.swing.*;
public class Tutor //NOTE CORRECTED CLASS NAME
{
String firstName;
String lastName;
String degreeLevel
public Tutor(String firstName, String lastName, String degreeLevel)
{
this.firstName = firstName;
this.lastName = lastName;
this.degreeLevel = degreeLevel;
}
public static void main (String[] args)
{
String ans;
List<Tutor> Tutor = new ArrayList<>();
for (int i = 0; i<Tutor.size; i++) //Tutor.size==0, will never run, I can't correct as I have no idea what you want to happen
{
ans = JOptionPane.showInputDialog(null,"Enter Tutor's Last Name, First Name, and Highest Level of Degree:");
Tutor = ans; //I have no idea whats going on here but Tutor should be initialised like new Tutor(string,string,string)
}
}
}