0% found this document useful (0 votes)
34 views2 pages

Gross Pay Calculator

This Java program uses a scanner to input an employee's name and whether they are full-time or part-time. It then calculates and outputs the employee's pay details. If full-time, it requests a monthly salary and outputs basic pay as that amount. If part-time, it requests hourly wage, hours worked, overtime hours, calculates basic and overtime pay, and outputs the gross pay amount. It handles any incorrect full-time/part-time entries.

Uploaded by

pass.num.2015
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views2 pages

Gross Pay Calculator

This Java program uses a scanner to input an employee's name and whether they are full-time or part-time. It then calculates and outputs the employee's pay details. If full-time, it requests a monthly salary and outputs basic pay as that amount. If part-time, it requests hourly wage, hours worked, overtime hours, calculates basic and overtime pay, and outputs the gross pay amount. It handles any incorrect full-time/part-time entries.

Uploaded by

pass.num.2015
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

Scanner;
public class try1
{
public static void main(String[] args) {
Scanner get = new Scanner(System.in);

System.out.print("Employee name: ");


String employeeName = get.nextLine();

System.out.print("Press F for Full time or P for Part Time: ");


String fullOrPart = get.nextLine();

if (fullOrPart.equals("F")){
System.out.print("Monthly Salary: ");
Double salaryF = get.nextDouble();
System.out.println("Enter eployee name: " + employeeName);
System.out.println("Press F for Full Time or P for Part Time: " +
fullOrPart);
System.out.println("---Full Time Employee---");
System.out.println("Enter Basic Pay: " + salaryF);
System.out.println("__________________________________");
System.out.println("Employee Name: " + employeeName);
System.out.println("Basic Pay: " + salaryF);
System.out.println("__________________________________");
System.out.println("Gross Pay: " + salaryF);
} else if (fullOrPart.equals("P")){
System.out.print("Enter rate per hour: ");
Double wageP = get.nextDouble();
System.out.print("Enter no. of hours worked: ");
Double numberHoursWork = get.nextDouble();
System.out.print("Enter no. of overtime: ");
Double numberOvertime= get.nextDouble();
Double basicPay = wageP * numberHoursWork;
Double overtimePay = numberOvertime * (wageP * 1.25);
Double grossPay = basicPay + overtimePay;
System.out.println("Enter employee name: " + employeeName);
System.out.println("Press F for Full Time or P for Part Time: " +
fullOrPart);
System.out.println("---Part Time Employee---");
System.out.println("Enter rate per hour: " + wageP);
System.out.println("Enter no. of hours worked: " + numberHoursWork);
System.out.println("Enter no. of overtime: " + numberOvertime);
System.out.println("__________________________________");
System.out.println("Employee Name: " + employeeName);
System.out.printf("Basic Pay: ");
System.out.printf("%.2f", basicPay);
System.out.println("");
System.out.printf("Overtime Pay: ");
System.out.printf("%.2f", overtimePay);
System.out.println("");
System.out.println("__________________________________");
System.out.printf("Gross Pay: ");
System.out.printf("%.2f", grossPay);
System.out.println("");
} else {
System.out.println("There's is an error in your Full time or Part time
input...");
System.out.println("Please try again...");
}

}
}

You might also like