Please write the following program in Java That last idea at PicoSoft didn\'t wo
ID: 3890014 • 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
VacationTest.java
import java.util.Scanner;
public class VacationTest {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter last name: ");
String lastName = scan.next();
System.out.println("Enter first name: ");
String firstName = scan.next();
System.out.println("Enter years worked: ");
int yearsWorked = scan.nextInt();
System.out.println("Enter salary: ");
int salary = scan.nextInt();
int bonus = 0;
int vacation = 0;
if(yearsWorked >=0 && yearsWorked <=3) {
vacation = 1;
} else if(yearsWorked >=4 && yearsWorked <=6) {
vacation = 2;
} else {
vacation = 3;
}
if(yearsWorked >=0 && yearsWorked <=4) {
bonus = 0;
} else if(yearsWorked >=5 && yearsWorked <=9) {
bonus = 200;
} else {
bonus = (salary* 5)/100;
}
System.out.println(firstName+" "+lastName+" gets "+vacation+" 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