20120129

Java Project #9: Pay Raise


/**
 * PayRaise computes pay raise and new salary for employees.
 * 
 * @author (Andrew Samuels) 
 * @version (02-19-2010)
 */

//import scanner
import java.util.Scanner;

public class PayRaise
{

    public static void main(String[] args)
    {
        //create variables
        double currentSalary;
        double payRaise;
        double newSalary;
        String word;
        char performanceRating;
        
        //create scanner
        Scanner keyboard = new Scanner(System.in);
        
        //capture current salary from user
        System.out.print("Please enter current salary: ");
        currentSalary = keyboard.nextDouble();
        
        //capture performance rating from user
        System.out.print("Please enter performance rating (A, B, C): ");
        word = keyboard.next();
        performanceRating = word.charAt(0);
        
        //determine pay raise using switch/case
        switch(performanceRating)
        {
            case 'A':
                payRaise = currentSalary * .06;
                newSalary = currentSalary + payRaise;
                System.out.println("Pay raise is: " + payRaise);
                System.out.println("New salary is: " + newSalary);
                break;
            case 'B':
                payRaise = currentSalary * .04;
                newSalary = currentSalary + payRaise;
                System.out.println("Pay raise is: " + payRaise);
                System.out.println("New salary is: " + newSalary);
                break;
            case 'C':
                payRaise = currentSalary * .02;
                newSalary = currentSalary + payRaise;
                System.out.println("Pay raise is: " + payRaise);
                System.out.println("New salary is: " + newSalary);
                break;
            default:
                System.out.println("Invalid performance rating");
        }
    }
}