Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Use an object of type String toadd aperson\'s name to the data assigned withi

ID: 3653405 • Letter: 1

Question

1. Use an object of type String toadd aperson's name to the data assigned within your program.

2.Use methods to carry out the work of your program.The main block of code should only consist of method calls to carry out the tasks.Remember that method namesbegin with a verb, reflecting the action being carried out by that block of code.Also keep in mindthat methods are narrow in focus,completing only one basic function. Most of the methods in this project will be relatively short; however, be aware of the fact that having only one method in this revision will not constitutesuccessful completion of this project.

Explanation / Answer

// Money
import java.util.Scanner;
public class Money
{ public static void main(String[] args)
{ int employeeNumber; double hourlyWage, hoursWorked, hoursWorkedOvertime, totalPay;
String name;
Scanner keyboard = new Scanner(System.in);
name=getName(keyboard);
employeeNumber = getNumber(keyboard);
hourlyWage=getHourly(keyboard);
hoursWorked =getRegHours(keyboard);  
hoursWorkedOvertime = getOverHours(keyboard);
totalPay=getTotal(hoursWorked,hourlyWage,hoursWorkedOvertime);
printit(totalPay,name,employeeNumber);

}

public static String getName(Scanner keyboard)
{System.out.println("What is the employee name?");
return keyboard.nextLine();
}
public static int getNumber(Scanner keyboard)
{System.out.println("What is the employee number?");
return Integer.parseInt(keyboard.nextLine());
}
public static double getHourly(Scanner keyboard)
{ System.out.println("What is the hourly wage amount?");
return Double.parseDouble(keyboard.nextLine());
}
public static double getRegHours(Scanner keyboard)
{ System.out.println("What is the number of regular hours worked?");
return Double.parseDouble(keyboard.nextLine());
}
public static double getOverHours(Scanner keyboard)
{ System.out.println("What is the number of overtime hours worked?");
return Double.parseDouble(keyboard.nextLine());
}
public static double getTotal(double hoursWorked,double hourlyWage,double hoursWorkedOvertime)
{return (hoursWorked*hourlyWage+hoursWorkedOvertime*hourlyWage*1.5);
}
public static void printit(double totalPay, String name,int number)
{System.out.println("Enployee name: "+name);
System.out.println("Employee number: "+number);
System.out.printf("Total Pay : $%.2f", totalPay);
}
}