The string value seems to appear yet I can not add a value to my calculations in the fulltime and part time.
This is the Main class for my inheritance
import java.util.Scanner;
public class RunEmployee1 {
private static String name;
private static double rate;
private static int hour;
private static double wage1;
private static double salary;
public String getName(){
return name;
}
public double getMonthlySalary(){
return salary;
}
public double getWage1(){
return wage1;
}
public static void main(String[]args){
char position;
Scanner sc = new Scanner(System.in);
System.out.println("Enter Employee name: ");
name = sc.nextLine();
System.out.println("Type F for Full time or P for Part time: ");
System.out.println("Use Capital Letter only!");
position = sc.next().charAt(0);
switch(position){
case 'F':
System.out.println("You are a Full time Employee!");
System.out.println("Enter your Monthly Wage: ");
salary = sc.nextDouble();
break;
case 'P':
System.out.println("You are a Part time Employee!");
System.out.println("Enter the number of hours you worked in: ");
hour = sc.nextInt();
System.out.println("Enter the hourly rate you are working in: ");
rate = sc.nextDouble();
break;
default :
System.out.println("You are not an Employee!");
}
Employee1 em1 = new Employee1();
FullTimeEmployee1 em2 = new FullTimeEmployee1();
PartTimeEmployee1 em3 = new PartTimeEmployee1();
em1.getName();
em1.writeOutput1();
em2.getMonthlySalary();
em2.writeOutput2(salary);
em3.getWage1();
em3.writeOutput3(wage1);
}
}
this is the child class
import java.util.Scanner;
public class FullTimeEmployee1 extends RunEmployee1{
private static double salary;
private static double newMonthlySalary;
Scanner sc = new Scanner(System.in);
public void setMonthlySalary(double newMonthlySalary){
this.salary = newMonthlySalary;
newMonthlySalary = sc.nextDouble();
}
public double getMonthlySalary(double newMonthlySalary){
salary = newMonthlySalary;
return salary = newMonthlySalary;
}
public void writeOutput2(double getMonthlySalary){
System.out.println("Employee's Full time Monthly Salary is: " +getMonthlySalary());
}
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
FullTimeEmployee1 em2 = new FullTimeEmployee1();
System.out.println("You are a Full time Employee!");
System.out.println("Enter your Monthly Wage: ");
salary = sc.nextDouble();
em2.getMonthlySalary();
em2.writeOutput2(salary);
}
}
and
import java.util.Scanner;
public class PartTimeEmployee1 extends RunEmployee1 {
private static double rate;
private static int hour;
private static double wage1;
private static double newMonthlyWage1;
Scanner sc = new Scanner(System.in);
public void setWage1(int hourWorked, double RatePerHour, double newMonthlyWage) {
RatePerHour = rate;
hourWorked = hour;
double wage1 = RatePerHour * hourWorked;
this.wage1 = newMonthlyWage;
newMonthlyWage = sc.nextDouble();
}
public double getWage1(double newMonthlyWage) {
wage1 = newMonthlyWage;
return wage1 = newMonthlyWage;
}
public void writeOutput3(double getWage1) {
System.out.println("Employee's Part time Monthly Wage is: " + +getWage1());
}
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
PartTimeEmployee1 em3 = new PartTimeEmployee1();
System.out.println("You are a Part time Employee!");
System.out.println("Enter the number of hours you worked in: ");
hour = sc.nextInt();
System.out.println("Enter the hourly rate you are working in: ");
rate = sc.nextDouble();
wage1 = rate * hour;
em3.getWage1();
em3.writeOutput3(wage1);
}
}
I should be showing results to the Salary value for both Fulltime and Parttime sub class.
Enter Employee name: Name Type F for Full time or P for Part time: Use Capital Letter only! P You are a Part time Employee! Enter the number of hours you worked in: 5 Enter the hourly rate you are working in: 100 Employee's name is: Name Employee's Full time Monthly Salary is: 0.0 Employee's Part time Monthly Wage is: 0.0