error explanation
Hi Guys,
I am building a program that calculates the wage of several workers, I decided to have a class WageCalculator that does most of the work and another called InputReader to get the values from the user. This program has a simple text interface.
this is the code for the wage calculator class at this stage:
/Code
public class WageCalculator
{
InputReader inputReader;
private float basicHourlyWage;
private String familyName;
private String firstName;
private String skillGrade;
private int hoursWorked;
int numberOfWeeks;
int[] hoursPerWeek = new int[7];
public WageCalculator()
{
inputReader = new InputReader();
start();
}
//main method
public static void main(String[] args)
{
WageCalculator wageCalculator = new WageCalculator();
}
// start method
private void start()
{
textUI();
}
private void textUI()
{
System.out.print("Basic Hourly Wage:");
basicHourlyWage = InputReader.getFloat();
System.out.print("Family Name:");
familyName = InputReader.getString();
System.out.print("First Name:");
firstName = InputReader.getString();
System.out.print("Skill Grade:");
skillGrade = InputReader.getString();
System.out.print("How many weeks shall I calculate?");
numberOfWeeks = InputReader.getInt();
for (int i = 1; i <= numberOfWeeks; i++)
{
System.out.print("Hours worked in Week" + i + ":");
hoursPerWeek = InputReader.getInt();
}
}
}
/~Code
The errors I get are these:
D:\UNI\JAVA\WageCalculator.java:52: non-static method getFloat() cannot be referenced from a static context
basicHourlyWage = InputReader.getFloat();
^
D:\UNI\JAVA\WageCalculator.java:54: non-static method getString() cannot be referenced from a static context
familyName = InputReader.getString();
^
D:\UNI\JAVA\WageCalculator.java:56: non-static method getString() cannot be referenced from a static context
firstName = InputReader.getString();
^
D:\UNI\JAVA\WageCalculator.java:58: non-static method getString() cannot be referenced from a static context
skillGrade = InputReader.getString();
^
D:\UNI\JAVA\WageCalculator.java:60: non-static method getInt() cannot be referenced from a static context
numberOfWeeks = InputReader.getInt();
^
D:\UNI\JAVA\WageCalculator.java:65: non-static method getInt() cannot be referenced from a static context
hoursPerWeek = InputReader.getInt();
^
Can someone tell me why am I getting this errors.
Best regards
Luis

