This program functions as it should, but I need to rewrite it so that there are only local variables, and they should pass from one method to another. Also the main block of code should only contain method calls to carry out the tasks. Could someone please show me how to do that?
import java.util.Scanner;
public class Project_Modification_v1
{
public static String employeeName;
public static int employeeID;
public static double hourlyWage;
public static double regularHours;
public static double overtimeHours;
public static double overtimePay;
public static double regularPay;
public static double totalPay;
public static Scanner reader = new Scanner(System.in);
public static void main(String args[])
{
enterInfo();
calculateInfo();
showResults();
}
public static void enterInfo()
{
System.out.print("Enter Employee Name: ");
employeeName = reader.nextLine();
System.out.print("Enter Employee ID: ");
employeeID = reader.nextInt();
System.out.print("Enter Hourly Wage: ");
hourlyWage = reader.nextDouble();
System.out.print("Enter Regular Hours: ");
regularHours = reader.nextDouble();
System.out.print("Enter Overtime Hours: ");
overtimeHours = reader.nextDouble();
}
public static void calculateInfo()
{
overtimePay = (overtimeHours * (1.5*hourlyWage));
regularPay = (regularHours*hourlyWage);
totalPay = (overtimePay+regularPay);
}
public static void showResults()
{
System.out.print(employeeName + " (no." + employeeID + ") has a total weekly pay of $" + totalPay);
}
}