Kali ini saya akan melanjutkan tentang penggajian akan tetapi sekarang kita akan menggunakan kotak dialog pada pemrograman java. .
Selamat mencoba, . .
import javax.swing.JOptionPane;
public class PayrollUsingDialogBox {
public static void main(String[] iriahus) {
String name = JOptionPane.showInputDialog(null,
"Employee's name",
"Input data",
JOptionPane.QUESTION_MESSAGE);
String hour = JOptionPane.showInputDialog(null,
"Number of hours worked in a week",
"Input data",
JOptionPane.QUESTION_MESSAGE);
String payRate = JOptionPane.showInputDialog(null,
"Input hourly pay rate",
"Input data",
JOptionPane.QUESTION_MESSAGE);
String federalTax = JOptionPane.showInputDialog(null,
"Input federal tax withholding (%)",
"Input data",
JOptionPane.QUESTION_MESSAGE);
String stateTax = JOptionPane.showInputDialog(null,
"Input state tax withholding (%)",
"Input data",
JOptionPane.QUESTION_MESSAGE);
double hourParse = Double.parseDouble(hour);
double payParse = Double.parseDouble(payRate);
double federaParse = Double.parseDouble(federalTax);
double stateParse = Double.parseDouble(stateTax);
double grossPay = hourParse * payParse;
double federalTaxDeduction = grossPay * (federaParse / 100);
double stateTaxDeduction = grossPay * (stateParse / 100);
double totalDeduction = federalTaxDeduction + stateTaxDeduction;
double netPay = grossPay - totalDeduction;
String output = "\nEmployee name\t: " + name + "\n" +
"Hours worked\t: " + hourParse + "\n" +
"Pay rate\t: " + payParse + "\n" +
"Deductions:\n" +
" Federal withholding (" + federaParse + "%)\t: " +
federalTaxDeduction + "\n" +
" State withholding (" + stateParse + "%)\t: " +
stateTaxDeduction + "\n" +
" Total deduction\t\t: " + totalDeduction + "\n" +
"Net pay\t\t: " + netPay;
JOptionPane.showMessageDialog(null, output);
}
}
Semoga bermanfaat, . .
0 Response to "Penggajian Menggunakan Kotak Dialog"
Post a Comment