Write a simple payroll program that will display the employee’s information. The program should perform
the following:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter the name: ");
String name = in.nextLine();
System.out.print("F(full time) or P(part time): ");
String type = in.nextLine();
if (type.equals("F")) {
System.out.print("Enter your monthly salary: ");
double salary = in.nextDouble();
System.out.println(name + " $" + salary);
} else if (type.equals("P")) {
System.out.print("Rate: ");
double rate = in.nextDouble();
System.out.print("The number of hours you worked: ");
double hours = in.nextDouble();
System.out.print("The numbers of overtime: ");
double overtime = in.nextDouble();
System.out.println(name + " $" + (rate * hours + rate * 1.25 * overtime));
} else {
System.out.println("Invalid input.");
}
}
}
Comments
Leave a comment