Penggajian

Assalamualaikum, . .
kali ini saya akan membagikan tentang penggajian pada pemrograman java, . .

import java.util.Scanner;

public class Payroll {

public static void main(String[] iriahus) {
@SuppressWarnings("resource")
Scanner s = new Scanner(System.in);

System.out.print("Enter employee's name: ");
String name = s.next();

System.out.print("Enter number of hours worked in a week: ");
double hour = s.nextDouble();

System.out.print("Enter hourly pay rate: ");
double payPerHour = s.nextDouble();

System.out.print("Enter federal tax withholding rate in percentage: ");
double federalTax = s.nextDouble();

System.out.print("Enter state tax withholding rate in percentage: ");
double stateTax = s.nextDouble();

double grossPay = hour * payPerHour;
double federalTaxDeduction = grossPay * (federalTax / 100);
double stateTaxDeduction = grossPay * (stateTax / 100);
double totalDeduction = federalTaxDeduction + stateTaxDeduction;
double netPay = grossPay - totalDeduction;

System.out.println(
"\nEmployee name\t: " + name + "\n" +
"Hours worked\t: " + hour + "\n" +
"Pay rate\t: " + payPerHour + "\n" +
"Deductions:\n" +
"  Federal withholding (" + federalTax + "%)\t: " +
federalTaxDeduction + "\n" +
"  State withholding (" + stateTax + "%)\t: " +
stateTaxDeduction + "\n" +
"  Total deduction\t\t: " + totalDeduction + "\n" +
"Net pay\t\t: " + netPay);
}

}

Semoga bermanfaat, . .

Subscribe to receive free email updates:

0 Response to "Penggajian"

Post a Comment