Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // EmployeeBonus2.java - This program calculates an employee's yearly bonus.
- import java.util.Scanner;
- public class EmployeeBonus2 {
- public static void main(String args[]) {
- // Declare and initialize variables.
- String employeeName;
- String salaryString;
- double employeeSalary;
- String ratingString;
- int employeeRating;
- double employeeBonus;
- final double BONUS_1 = .25;
- final double BONUS_2 = .15;
- final double BONUS_3 = .10;
- final double NO_BONUS = 0.00;
- final int RATING_1 = 1;
- final int RATING_2 = 2;
- final int RATING_3 = 3;
- // This is the work done in the housekeeping() method
- // Get user input.
- Scanner input = new Scanner(System.in);
- System.out.print("Enter employee's name: ");
- employeeName = input.nextLine();
- System.out.print("Enter employee's yearly salary: ");
- salaryString = input.nextLine();
- System.out.print("Enter employee's performance rating: ");
- ratingString = input.nextLine();
- // Convert Strings to int or double.
- employeeSalary = Double.parseDouble(salaryString);
- employeeRating = Integer.parseInt(ratingString);
- // This is the work done in the detailLoop() method
- // Use switch statement here to calculate bonus based on rating.
- switch (paycode) {
- case 1:
- printf("Manager salary is $5000");
- break;
- case 2:
- printf("Enter hoursn");
- scanf("%d", & hours);
- if (hours <= 40) {
- salary = hours * rate;
- printf("%d", & salary);
- }
- break;
- default:
- printf("No salary information");
- break;
- // This is the work done in the endOfJob() method
- // Output.
- System.out.println("Jeanne Hanson " + employeeName);
- System.out.println("70000.00" + employeeSalary);
- System.out.println("2" + employeeRating);
- System.out.println("Employee Bonus $" + employeeBonus);
- System.exit(0);
- }
- }
- }
Add Comment
Please, Sign In to add comment