السلام عليكم و رحمة الله و بركاته..
طلب مني حل Assignment.. و حاولت و لكن ظهرت أخطاء في كتابته..
و أريد منكم المساعدة إذا سمحتوا..
حاولت إرفاق ال class ولكني لم أستطع لذا نسخته هنا..
class Employee{
String empName;
int empHour , empRate;
double gross, tax, net;
public double computeGross(){
if (empHour<=40)
gross= empHour*empRate;
else
if (empHour>gross)
gross=1200+(empHour-40)*50;
else
System.out.print("The employee hour is illegle!");
return gross;
}
public double computeTax(double gross){
if (gross<1000)
tax=1.5/100;
else
if (gross>1000&&gross<3000)
tax=2.5/100;
else
if (gross>=30000)
tax=4/100;
else
System.out.println("The salary is illegle");
return tax;
}
public double computeNet(double gross ,double tax){
net=gross-tax;
return net;
}
Employee(String name ,int hour ,int rate){
empName=name;
empHour=hour;
empRate=rate;
}
}وهذا class المناداة..
import javax.swing.*;
class TestEmployee{
public static void main (String []args){
String name=JOptionPane.showInputDialog("Enter the employee name:");
String userInput1=JOptionPane.showInputDialog("Enter how much the employee has of hours:");
int hour=Integer.parseInt(userInput1);
String userInput2=JOptionPane.showInputDialog("Enter how much the employee has of rate:");
int rate=Integer.parseInt(userInput2);
String userInput3=JOptionPane.showInputDialog("Enter how much the employee has of gross:");
double gross=Double.parseDouble(userInput3);
String userInput4=JOptionPane.showInputDialog("Enter The how much the employee has of tax:");
double tax=Double.parseDouble(userInput4);
Employee EmployeeName= new Employee(name, hour, rate);
JOptionPane.showMessageDialog(null,"The gross is:"+ EmployeeName.computeGross());
JOptionPane.showMessageDialog(null,"The tax is:"+EmployeeName.computeTax(gross));
JOptionPane.showMessageDialog(null,"The net salary is:"+EmployeeName.computeNet(gross, tax));
System.exit(0);
}
}فضلا عند كتابة كود برمجي يرجى تظليله ومن ثم ضغط الزر #
