Answer to Question #272443 in Java | JSP | JSF for dreaper

Question #272443
  1. Write a Java program that computes the salary of an employee. The program should perform the following:
  • Ask the user to enter an employee name, pay rate, and total hours of work.
  • Compute the salary of the employee
  • Display the entered information of employee and his salary

2. Name the class as SalaryCalculator and save the file

3. Compile and execute the program using command prompt

4. Correct syntax and logical errors if there is any


1
Expert's answer
2021-11-28T11:44:24-0500
import java.util.Scanner;


public class SalaryCalculator {


	/**
	 * The start point of the program
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner keyBoard = new Scanner(System.in);
		System.out.print("Enter an employee name: ");
		String employeeName = keyBoard.nextLine();
		System.out.print("Enter an employee pay rate: ");
		double payRate = keyBoard.nextDouble();
		System.out.print("Enter an employee total hours of work: ");
		double totalHoursWork = keyBoard.nextDouble();
		double salary = payRate * totalHoursWork;


		System.out.println("\nEmployee name: " + employeeName);
		System.out.printf("Employee pay rate: %.2f\n", payRate);
		System.out.printf("Employee total hours of work: %.2f\n", totalHoursWork);
		System.out.printf("Employee salary: %.2f\n", salary);
		keyBoard.close();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS