Please write the following program in Java That last idea at PicoSoft didn\'t wo
ID: 3890315 • Letter: P
Question
Please write the following program in Java
That last idea at PicoSoft didn't work out too well … management has a massive public relations disaster on their hands, and thus they decide to revise the bonus structure, as well as give eveyone some additional vacation time.
Write a program that reads in (from the keyboard) the following information about an employee:
Last name
First name
Years worked (a whole number)
Annual salary
An employee's vacation time is based upon the following table:
Bonuses are determined by the following table:
Your program should read in the information for an employee, calculate the vacation time and bonus amount for the employee, and display the employee's name, number of years worked, number of weeks of vacation and amount of bonus (on a single line). Please note that you are to print the actual amount of the bonus (calculated as 5% of the annual salary), and not simply the words 5% of salary".
This should be done for eight (8) employee (using a for loop).
Test Run
Enter last name: Weiss
Enter first name: Gerald
Enter years worked: 1
Enter salary: 100
Gerald Weiss gets 1 weeks vacation, and a bonus of $0
Enter last name: Arnow
Enter first name: Davis
Enter years worked: 3
Enter salary: 200
Davis Arnow gets 1 weeks vacation, and a bonus of $0
Enter last name: Tenenbaum
Enter first name: Aaron
Enter years worked: 4
Enter salary: 100
Aaron Tenenbaum gets 2 weeks vacation, and a bonus of $0
Enter last name: Thurm
Enter first name: Joe
Enter years worked: 6
Enter salary: 100
Joe Thurm gets 2 weeks vacation, and a bonus of $200
Enter last name: Whitlock
Enter first name: Paula
Enter years worked: 7
Enter salary: 400
Paula Whitlock gets 3 weeks vacation, and a bonus of $200
Enter last name: Jones
Enter first name: Jackie
Enter years worked: 9
Enter salary: 500
Jackie Jones gets 3 weeks vacation, and a bonus of $200
Enter last name: Dreizen
Enter first name: Phil
Enter years worked: 10
Enter salary: 1000
Phil Dreizen gets 3 weeks vacation, and a bonus of $50
Enter last name: Augenstein
Enter first name: Moshe
Enter years worked: 12
Enter salary: 1500
Moshe Augenstein gets 3 weeks vacation, and a bonus of $75
Explanation / Answer
EmpVacationAndBonus.java
import java.util.Scanner;
public class EmpVacationAndBonus {
public static void main(String[] args) {
// Declaring variables
String lastname, firstname;
int yearsWorked, vacationWeeks = 0;
double bonus = 0, annSal;
/*
* Creating an Scanner class object which is used to get the inputs
* entered by the user
*/
Scanner sc = new Scanner(System.in);
for (int i = 1; i <= 8; i++) {
// Getting the first name entered by the user
System.out.print(" Enter last name:");
lastname = sc.next();
// Getting the last name entered by the user
System.out.print("Enter first name:");
firstname = sc.next();
// Getting the no of years entered by the user
System.out.print("Enter years worked:");
yearsWorked = sc.nextInt();
// Getting the annual salary entered by the user
System.out.print("Enter salary:");
annSal = sc.nextDouble();
// based on years worked find the no of vacation weeks and bonus
if (yearsWorked >= 0 && yearsWorked <= 3)
vacationWeeks = 1;
else if (yearsWorked >= 4 && yearsWorked <= 6)
vacationWeeks = 2;
else if (yearsWorked >= 7)
vacationWeeks = 3;
if (yearsWorked >= 0 && yearsWorked <= 4)
bonus = 0;
else if (yearsWorked >= 5 && yearsWorked <= 9)
bonus = 200;
else if (yearsWorked >= 7)
bonus = annSal * 0.05;
// Displaying the output
System.out.println(firstname + " " + lastname + " gets " + vacationWeeks + " weeks vacation, and a bonus of $" + bonus);
}
}
}
______________________
Output:
Enter last name:Weiss
Enter first name:Gerald
Enter years worked:1
Enter salary:100
Gerald Weiss gets 1 weeks vacation, and a bonus of $0.0
Enter last name:Arnow
Enter first name:Davis
Enter years worked:3
Enter salary:200
Davis Arnow gets 1 weeks vacation, and a bonus of $0.0
Enter last name:Tenenbaum
Enter first name:Aaron
Enter years worked:4
Enter salary:100
Aaron Tenenbaum gets 2 weeks vacation, and a bonus of $0.0
Enter last name:Thurm
Enter first name:Joe
Enter years worked:6
Enter salary:100
Joe Thurm gets 2 weeks vacation, and a bonus of $200.0
Enter last name:Whitlock
Enter first name:Paula
Enter years worked:7
Enter salary:400
Paula Whitlock gets 3 weeks vacation, and a bonus of $200.0
Enter last name: Jones
Enter first name: Jackie
Enter years worked: 9
Enter salary: 500
Jackie Jones gets 3 weeks vacation, and a bonus of $200
Enter last name: Dreizen
Enter first name: Phil
Enter years worked: 10
Enter salary: 1000
Phil Dreizen gets 3 weeks vacation, and a bonus of $50
Enter last name: Augenstein
Enter first name: Moshe
Enter years worked: 12
Enter salary: 1500
Moshe Augenstein gets 3 weeks vacation, and a bonus of $75
_____________Could you rate me well.Plz .Thank You