السلام عليكم ورحمة الله وبركاته
أرجو منكم تصحيح الأخطاء في هذا البرنامج ولكم جزيل الشكر :)
الأخطاء تحتها خط :)
package EmployeeTest1;
import java.util.Scanner; // program uses Scanner
class EmployeeTestt
{
public static void main(String[] args) //meain method to execute the program
{
EmployeeList []E = new EmployeeList[5];
EmployeeTestt Scanner input = new Scanner(System.in);
for ( int i = 0; i < 5; i++ )
{
EmployeeTestt EmployeeList = new EmployeeTestt();
//EmployeeTestt [] Employeelist = new EmployeeTestt();
E[].Employee();
E[].ExtraHours();
E[].getEmployee(); }}}
//---------------------------------------------------------------------------------------------
package EmployeeTest1
import java.util.Scanner;
// program uses Scanner
class EmployeeList {
// Definition of the three variables
String FirstName;
String LastName;
double HourlyRate;
double newhoursPermonth;
double MonthlySalary;
//zero argument constructor
void Employee()
{
FirstName = null;
LastName = null;
HourlyRate=0.0;
newhoursPermonth=0.0;
MonthlySalary =0.0;
}
// constructor an argument that initializes the three variables
void Employee (String firstname , String lastname , double Salary,
double hoursPermonthe, double hourlyrate)
{
FirstName = firstname;
LastName = lastname;
HourlyRate = hourlyrate;
newhoursPermonth = hoursPermonthe;
MonthlySalary = Salary;
}//end constructor
// method to set the emplloyee info
void setEmployee (String newFirstName, String newLastName,
double newhoursPermonth,double newhourlyrate, double newSalary)
{
EmployeeTestt employee1 = new EmployeeTestt(); // create firs Employee object name as employee1
Scanner input = new Scanner(System.in);
System.out.println("Pleas enter employee first name: ");
newFirstName = input.nextLine();
System.out.println("Pleas enter employee last name: ");
newLastName = input.nextLine();
System.out.println("Pleas enter employee number of hours in one monthe : ");
newhoursPermonth = input.nextDouble();
System.out.println("Pleas enter employee hourly rate: ");
newhourlyrate = input.nextDouble();
}//end method setfirstname
double ExtraHours(double newhoursPermonth, double newhourlyrate)
{
if(newhoursPermonth<=160)
{
MonthlySalary=(newhoursPermonth*newhourlyrate);
}
else
{
MonthlySalary=(newhourlyrate*newhoursPermonth)+((newhourlyrate*1.5)*(newhoursPermonth-160));
}
return MonthlySalary;
}
void getEmployee(String newFirstName, String newLastName,
double newhoursPermonth,double newhourlyrate, double newSalary)
{
System.out.print("\t\tFirstName\t\tLastName\t\tNumber Of Hours/week\t\tHourly rate\tMonthly Salary\nemployee\t");
System.out.print(newFirstName);
System.out.print("\t\t");
System.out.print(newLastName);
System.out.print("\t\t");
System.out.print(newhoursPermonth);
System.out.print("\t\t");
System.out.print(newhourlyrate);
System.out.print("\t\t");
System.out.print(MonthlySalary);
}
}//end class
والسؤال تبع البرنامج
Develop a Java application that determines the gross pay for each of 5 employees. You are to extend the Employee class created in homework 1. The company pays straight time for the first 40 hours worked by each employee and time and a half for all hours worked in excess of 40. The following employee information is entered:
• First Name
• Last Name
• Monthly Salary
• Number of hours worked last week
• Hourly rate
Your program should input this information for each employee, then determine and display the employee’s monthly salary.
:blush: