i need help for this excersise (3.10 in java how to program book 8th edition)~~
ID: 3629887 • Letter: I
Question
i need help for this excersise (3.10 in java how to program book 8th edition)~~ i need please help me i need it today...the qustion is:
(Employee Class) create class called epmloyee that includes three inhance variables-- a first name (type string), a last name (type string) and monthly salary (double). Provide a constructor that initialize the three inhance variables. provide a set and a get method for each inhance variables. if the monthly salary is not positive do set its value. write a test application named employeetest that demonstrates class employee's capabilities. creat two employee object and display each object's yearly salary. then give each employee a 10% raise and display each employees yearly salary again.
Explanation / Answer
import java.util.Scanner;
public class EmployeeTest
{
// main method begins execution of Java application
public static void main( String args[] )
{
Employee employee1 = new Employee();
Employee employee2 = new Employee();
Scanner input = new Scanner( System.in );
String first;
String last;
double salary;
System.out.print( "Enter the first name of the first employee: " );
first = input.nextString();
employee1.setfirstName( first );
System.out.print( "Enter the last name of the first employee: " );
last = input.nextString();
employee1.setlastName( last );
System.out.print( "Enter the first employee's monthly salary: " );
salary = input.nextDouble();
employee1.setSalary( salary );
System.out.print( "Enter the first name of the second employee: " );
first = input.nextString();
employee2.setfirstName( first );
System.out.print( "Enter the last name of the second employee: " );
last = input.nextString();
employee2.setlastName( last );
System.out.print( "Enter the second employee's monthly salary: " );
salary = input.nextDouble();
employee2.setSalary( salary );
//displays employee's salary and full name.
System.out.printf( "Now displaying employees' full names and annual
salary. ");
System.out.printf( employee1.getfirstName()," ", employee1.getlastName(),
" ", employee1.getSalary() * 12, " " );
System.out.printf( employee2.getfirstName()," ", employee2.getlastName(),
" ", employee2.getSalary() * 12, " " );
// displays where raise id giving
System.out.printf( "Now applying a 10% raise to each employee and
displaying the updated information. ");
System.out.printf( employee1.getfirstName()," ", employee1.getlastName(),
" ", ((employee1.getSalary() * 12)+ (employee1.getSalary() * 12)*0.1)), " " );
System.out.printf( employee2.getfirstName()," ", employee2.getlastName(),
" ", ((employee2.getSalary() * 12)+ (employee2.getSalary() * 12)*0.1)), " " );
}//end main
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.