Okay, I am trying to make the program run from a few methods and I'm running into errors left and right:
import java.util.Scanner; //Takes user input
import java.text.*; //import for the decimal format
public class Mod_of_3_4 {
//Constant Vars
int employeeId;
int regHours;
int overHours;
double wage;
double totalPay;
//Day 1 Var
int regHours1;
int overHours1;
//Day 2 Var
int regHours2;
int overHours2;
//Day 3 Var
int regHours3;
int overHours3;
//Day 4 Var
int regHours4;
int overHours4;
//Day 5 Var
int regHours5;
int overHours5;
public static void main(String[] args) {
//Methods
inputID();
inputWage();
inputDays();
calcPay();
calcTotal();
printResults();
}
//Employee ID Number
public int inputID() {
System.out.println("Enter Employee ID: ");
Scanner scan = new Scanner(System.in);
int employeeId = scan.nextInt();
}
//Hourly Wage
public double inputWage() {
System.out.println("Enter the Hourly Wage: ");
Scanner scan3 = new Scanner(System.in);
double wage = scan3.nextDouble();
}
//Input Daily Hours
public int inputDays() {
//Day 1
System.out.println("Monday: Enter the Number of Regular Hours: ");
Scanner scan1 = new Scanner(System.in);
int regHours1 = scan1.nextInt();
System.out.println("Monday: Enter the Number of Over Time Hours: ");
Scanner scan2 = new Scanner(System.in);
int overHours1 = scan2.nextInt();
//Day 2
System.out.println("Tuesday: Enter the Number of Regular Hours: ");
Scanner scan4 = new Scanner(System.in);
int regHours2 = scan4.nextInt();
System.out.println("Tuesday: Enter the Number of Over Time Hours: ");
Scanner scan5 = new Scanner(System.in);
int overHours2 = scan5.nextInt();
//Day 3
System.out.println("Wednesday: Enter the Number of Regular Hours: ");
Scanner scan6 = new Scanner(System.in);
int regHours3 = scan6.nextInt();
System.out.println("Wednesday: Enter the Number of Over Time Hours: ");
Scanner scan7 = new Scanner(System.in);
int overHours3 = scan7.nextInt();
//Day 4
System.out.println("Thursday: Enter the Number of Regular Hours: ");
Scanner scan8 = new Scanner(System.in);
int regHours4 = scan8.nextInt();
System.out.println("Thursday: Enter the Number of Over Time Hours: ");
Scanner scan9 = new Scanner(System.in);
int overHours4 = scan9.nextInt();
//Day 5
System.out.println("Friday: Enter the Number of Regular Hours: ");
Scanner scan10 = new Scanner(System.in);
int regHours5 = scan10.nextInt();
System.out.println("Friday: Enter the Number of Over Time Hours: ");
Scanner scan11 = new Scanner(System.in);
int overHours5 = scan11.nextInt();
}
//Reformat and Calculate
public int calcPay() {
//Decimal Format
DecimalFormat df = new DecimalFormat("#.##");
//Calculations
int regHours = (regHours1 + regHours2 + regHours3 + regHours4 + regHours5);
int overHours = (overHours1 + overHours2 + overHours3 + overHours4 + overHours5);
}
public double calcTotal() {
double totalPay = (regHours * wage) + (overHours * (wage * 1.5));
}
//Print Results
public void printResults() {
System.out.println("Total pay for the week is: $"+df.format(totalPay));
System.out.println("For Employee #" + employeeId);
}
}
I'm getting the error messages:
--------------------Configuration: Mod of 3.4 - JDK version 1.7.0_03 <Default> - <Default>--------------------
C:\Users\Andrew\Documents\JCreator Pro\MyProjects\Mod of 3.4\src\Mod_of_3_4.java:41: error: non-static method inputID() cannot be referenced from a static context
inputID();
^
C:\Users\Andrew\Documents\JCreator Pro\MyProjects\Mod of 3.4\src\Mod_of_3_4.java:42: error: non-static method inputWage() cannot be referenced from a static context
inputWage();
^
C:\Users\Andrew\Documents\JCreator Pro\MyProjects\Mod of 3.4\src\Mod_of_3_4.java:43: error: non-static method inputDays() cannot be referenced from a static context
inputDays();
^
C:\Users\Andrew\Documents\JCreator Pro\MyProjects\Mod of 3.4\src\Mod_of_3_4.java:44: error: non-static method calcPay() cannot be referenced from a static context
calcPay();
^
C:\Users\Andrew\Documents\JCreator Pro\MyProjects\Mod of 3.4\src\Mod_of_3_4.java:45: error: non-static method calcTotal() cannot be referenced from a static context
calcTotal();
^
C:\Users\Andrew\Documents\JCreator Pro\MyProjects\Mod of 3.4\src\Mod_of_3_4.java:46: error: non-static method printResults() cannot be referenced from a static context
printResults();
^
C:\Users\Andrew\Documents\JCreator Pro\MyProjects\Mod of 3.4\src\Mod_of_3_4.java:130: error: cannot find symbol
System.out.println("Total pay for the week is: $"+df.format(totalPay));
^
symbol: variable df
location: class Mod_of_3_4
7 errors
Process completed.
I've tried to fix the errors and I'm only getting more, any help would be much appreciated! Also, how can I do the loops mentioned in the post above?