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
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();
}
}
Comments
Leave a comment