- Joined
- Jul 2, 2019
- Posts
- 823
- Solutions
- 1
- Reaction
- 1,216
- Points
- 449
Ito Task
"write a program by creating an "Employee" class having the following method and print the final salary.
-'getinfo()'which takes the salary, number of hours of work per day of employee as parameter
-_'AdSal()'which adds P100 to salary of the employee if its is less than P500.
-'AddWork()'which adds P500 to salary of the employee if the number of hours of work per day is more than 6 hours."
TAPOS ito po code ko
class Main{
float.salary.no_of_hours
void getinfo(float no_of_hours,float salary)
{
this.salary=salary;
this.no_of_hours_=no_of_hours;
}
void addSalary();
Test(salary<500);
salary+=100()
void addWork();
Test(no_of_hours>6)
salary+=500;
void printSalary();
System.out.println("Final Salary of the employee ="+salary+"$");
public static void main(String[] args)
System.out.println("Enter the salary of Employee:");
float salary=sc.nextFloat;
System.out.println("Enter the number of working hours:");
float no_of_hrs=sc.nextFloat;
Employee emp = new Employee2();
emp.getinfo(no_of_hrs.salary);
emp.addSalary();
emp.addWork();
emp.printSalary();
}
}
ITO PO ERROR diko kasi maintindihan kung ano po <identifier> meaning nyan hehe
+ javac -cp . Main.java
Main.java:3: error: <identifier> expected
float.salary.no_of_hours
^
Main.java:12: error: invalid method declaration; return type required
Test(salary<500);
^
Main.java:12: error: îllégâl start of type
Test(salary<500);
^
Main.java:14: error: <identifier> expected
salary+=100()
^
Main.java:14: error: ';' expected
salary+=100()
^
Main.java:19: error: invalid method declaration; return type required
Test(no_of_hours>6)
^
Main.java:19: error: <identifier> expected
Test(no_of_hours>6)
^
Main.java:26: error: <identifier> expected
System.out.println("Final Salary of the employee ="+salary+"$");
^
Main.java:26: error: îllégâl start of type
System.out.println("Final Salary of the employee ="+salary+"$");
^
Main.java:28: error: ';' expected
public static void main(String[] args)
^
Main.java:33: error: <identifier> expected
System.out.println("Enter the number of working hours:");
^
Main.java:33: error: îllégâl start of type
System.out.println("Enter the number of working hours:");
^
Main.java:37: error: <identifier> expected
emp.getinfo(no_of_hrs.salary);
^
Main.java:37: error: <identifier> expected
emp.getinfo(no_of_hrs.salary);
^
Main.java:38: error: <identifier> expected
emp.addSalary();
^
Main.java:39: error: <identifier> expected
emp.addWork();
^
Main.java:40: error: <identifier> expected
emp.printSalary();
^
Main.java:42: error: class, interface, or enum expected
}
^
18 errors
+ java -cp . Main
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main
"write a program by creating an "Employee" class having the following method and print the final salary.
-'getinfo()'which takes the salary, number of hours of work per day of employee as parameter
-_'AdSal()'which adds P100 to salary of the employee if its is less than P500.
-'AddWork()'which adds P500 to salary of the employee if the number of hours of work per day is more than 6 hours."
TAPOS ito po code ko
class Main{
float.salary.no_of_hours
void getinfo(float no_of_hours,float salary)
{
this.salary=salary;
this.no_of_hours_=no_of_hours;
}
void addSalary();
Test(salary<500);
salary+=100()
void addWork();
Test(no_of_hours>6)
salary+=500;
void printSalary();
System.out.println("Final Salary of the employee ="+salary+"$");
public static void main(String[] args)
System.out.println("Enter the salary of Employee:");
float salary=sc.nextFloat;
System.out.println("Enter the number of working hours:");
float no_of_hrs=sc.nextFloat;
Employee emp = new Employee2();
emp.getinfo(no_of_hrs.salary);
emp.addSalary();
emp.addWork();
emp.printSalary();
}
}
ITO PO ERROR diko kasi maintindihan kung ano po <identifier> meaning nyan hehe
+ javac -cp . Main.java
Main.java:3: error: <identifier> expected
float.salary.no_of_hours
^
Main.java:12: error: invalid method declaration; return type required
Test(salary<500);
^
Main.java:12: error: îllégâl start of type
Test(salary<500);
^
Main.java:14: error: <identifier> expected
salary+=100()
^
Main.java:14: error: ';' expected
salary+=100()
^
Main.java:19: error: invalid method declaration; return type required
Test(no_of_hours>6)
^
Main.java:19: error: <identifier> expected
Test(no_of_hours>6)
^
Main.java:26: error: <identifier> expected
System.out.println("Final Salary of the employee ="+salary+"$");
^
Main.java:26: error: îllégâl start of type
System.out.println("Final Salary of the employee ="+salary+"$");
^
Main.java:28: error: ';' expected
public static void main(String[] args)
^
Main.java:33: error: <identifier> expected
System.out.println("Enter the number of working hours:");
^
Main.java:33: error: îllégâl start of type
System.out.println("Enter the number of working hours:");
^
Main.java:37: error: <identifier> expected
emp.getinfo(no_of_hrs.salary);
^
Main.java:37: error: <identifier> expected
emp.getinfo(no_of_hrs.salary);
^
Main.java:38: error: <identifier> expected
emp.addSalary();
^
Main.java:39: error: <identifier> expected
emp.addWork();
^
Main.java:40: error: <identifier> expected
emp.printSalary();
^
Main.java:42: error: class, interface, or enum expected
}
^
18 errors
+ java -cp . Main
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main