/*
* Problem 10 -- Calculating the salary of a specific person
* at a company
*
* Author: SOME GUY
* Creation Date: 2010-09-20
* Modified Date: 2010-09-28
* Description: Given the employee job classification,
* Education background, merit rating
* years of service and base pay, calculate
* the percent of salary adjustment for each
* employee
*
* NOTE: TABLE TOO LARGE -- REFER TO
* http://192.168.0.3/~wcrum/cs/pcc/problems/problem10.shtml
*
*/
import java.util.*;
public class calcSalary
{
public static void main( String args[] )
{
/*
* These variables define the FINAL number
* bleh...
*/
double jobRate; //the job rate adjustment
//based on service level
double merit; //the merit level of the person
double education; //the amount of education they have had
double service; //the amount of time they worked at the
//company
int basePay; //the base pay of the worker before the salary
//adjustment
/*--------------------------------------------*/
/*
* get the base payment of everything
*/
basePay = getBasePay();
/*
* BEGIN CODE TO DETERMINE JOB STATUS
*
*/
int jobChoice;
String jobWord;
//double jobRate; might just keep this at the top
jobChoice = getJobChoice();
jobWord = getJobWord( jobChoice );
jobRate = getJobRate( jobChoice );
/* END JOB PART ------------------------------*/
/*
* Begin merit identification
*/
int meritChoice;
String meritWord;
//double merit; //might just keep this at the top
meritChoice = getMeritChoice();
meritWord = getMeritWord( meritChoice );
merit = getMeritRate( meritChoice );
/* End merit identifcation-------------------*/
/* ---------------------------------------------
* Begin education identification...
*/
int educationChoice;
String educationWord;
//double education; //might just keep this at the top...
educationChoice = getEducationChoice();
educationWord = getEducationWord( educationChoice );
education = getEducationRate( educationChoice );
/* End education identifcation------------------ */
/* -----------------------------------------------
* Begin service identification
* bleh...
*/
int serviceYears; //the number of years worked
//double service; //already defined at the top
serviceYears = getServiceChoice();
service = getServiceRate( serviceYears );
/*-----------------------------------------------
* BEGIN CALCULATIONS
*/
double finalPay; //the final salary with adjustment
finalPay = calcFinal( jobRate, merit, education, basePay, service );
printResults( jobRate, merit, education, basePay, finalPay, service, jobWord, meritWord, educationWord, serviceYears );
}
/*AOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAOAO
* Begin functions related to job calculations...
* jobWord --> the specific job "word" to be used when printing results
* jobRate --> the actual rate used in calculations..
*
*/
/*
* retireive from the user, the job rate AS A WORD
* @return jobWord --> the percentage of job
*
*/
public static int getJobChoice() {
int number; //the specific percentage
Scanner inputBuffer = new Scanner(System.in);
System.out.print("Job classification menu:\n\r" +
"Press 1 for management level\n\r" +
"Press 2 for technical level\n\r" +
"Press 3 for service level\n\rClassification> "
);
number = inputBuffer.nextInt();
return number;
}
/*
* return jobChoice as a WORD
* @param jobChoice --> the job choice as a choice number
* @return jobWord --> the word associated with the choice
*
*/
public static String getJobWord( int jobChoice )
{
String wordUp;
switch ( jobChoice )
{
case 1:
wordUp = "Management";
break;
case 2:
wordUp = "Technical";
break;
default:
wordUp = "Service";
}
return wordUp;
}
/*
* return jobChoice as a number
* @param jobChoice --> the job choice
* @return jobRate --> the job choice as a rate to be calculated
*/
public static double getJobRate( int jobChoice )
{
double number; //the number blah
switch (jobChoice)
{
case 1:
number = 0.01;
break;
case 2:
number = 0.015;
break;
default:
number = 0.016;
break;
}
return number;
}
/*
* THIS ENDS FUNCTIONS RELATED TO JOB CALCULATIONS
*/
/*
* BEGIN MERIT IDENTIFICATION
* IMPORTANT VARS:
* meritWord --> the specific word related to the number
* merit --> the number used for calculation
*/
/*
* identify the specific choice of merit, then export as a number
* @return meritChoice --> the internal choice as a number
*
*/
public static int getMeritChoice()
{
int number; //the specific percentage
Scanner inputBuffer = new Scanner(System.in);
System.out.print("Merit classification menu:\n\r" +
"Press 1 for poor service\n\r" +
"Press 2 for good service\n\r" +
"Press 3 for excellent service\n\rClassification> "
);
number = inputBuffer.nextInt();
return number;
}
/*
* return the choice of merit as a word.
* @param meritChoice --> the specific choice of merit from the menu
* @return meritWord --> the specific merit word returned
*/
public static String getMeritWord( int meritChoice )
{
String wordUp;
switch ( meritChoice )
{
case 1:
wordUp = "Poor";
break;
case 2:
wordUp = "Good";
break;
default:
wordUp = "Excellent";
break;
}
return wordUp;
}
/*
* return meritChoice as a number.
*
* @param meritChoice --> the specific merit choice
* @return meritRate --> the specific merit rate returned as a number
*
*/
public static double getMeritRate( int meritChoice )
{
double number;
switch( meritChoice )
{
case 1:
number = -0.04;
break;
case 2:
number = 0.015;
break;
default:
number = 0.02;
break;
}
return number;
}
/*
* THIS ENDS THE MERIT IDENTIFICATION BLAHBLAHBLAH.
*/
/*
* THIS BEGINS THE EDUCATION IDENTIFICATION
*
*/
/*
* Return the choice of education from the menu
* @return educationChoice --> the specific choice
*/
public static int getEducationChoice()
{
int number; //the number of something
Scanner inputBuffer = new Scanner(System.in);
System.out.print("Education menu:\n\r" + "Press 1 for High School education.\n\r" + "Press 2 for College education.\n\r" + "Press 3 for Graduate school education.\n\r" + "Classification> ");
number = inputBuffer.nextInt();
return number;
}
/*
* take from educationChoice and return a word
* associated with it.
* @param educationChoice --> the specific choice chosen
* from the menu
*
* @return educationWord --> the specific word associated with
* the choice
*
*/
public static String getEducationWord( int educationChoice )
{
String wordUp; //the word associated with the number.
switch( educationChoice )
{
case 1:
wordUp = "High School";
break;
case 2:
wordUp = "College";
break;
default:
wordUp = "Graduate School";
break;
}
return wordUp;
}
/*
* take the educationChoice and return a rate to be calculated
* @param educationChoice --> the choice taken from the menu
* @return education --> the specific rate to be calculated
*
*/
public static double getEducationRate( int educationChoice )
{
double number; //the number to be calculated with.
switch( educationChoice )
{
case 1:
number = 0.01;
break;
case 2:
number = 0.012;
break;
default:
number = 0.0135;
break;
}
return number;
}
/*
* this ends the education identification
*
*/
/*
* this begins the service identification.
*
*/
/*
* Print out the menu, then return the classification
* AS A NUMBER TO BE USED LATER.
*
* @return serviceChoice --> the choice number.
*
*/
public static int getServiceChoice()
{
int number; //number used for figuring out choice
Scanner inputBuffer = new Scanner(System.in);
System.out.print("Service identification menu:\n\r" + "Enter how many years they have worked.\n\r" + "Round the number to the next WHOLE YEAR\n\r" + "Classification> " );
number = inputBuffer.nextInt();
return number;
}
/*
* Calculate the percentage of years worked
* @param serviceYears --> number of years worked
*/
public static double getServiceRate( int serviceYears )
{
double serviceRate; //the rate to calculate the salary by
serviceRate = 0.01; //0 to 10 years
if (serviceRate > 10) {
serviceRate = 0.012;
}
if (serviceRate > 20) {
serviceRate = ( 0.0135 + ( 0.007 * 20 ) );
}
return serviceRate;
}
/*
* this ends service identification.
*
*/
/*
* get from the user, the base pay
* @return basePay --> the base number to calculate
* everything off of
*
*/
public static int getBasePay()
{
int number; //number used for base pay
Scanner inputBuffer = new Scanner(System.in);
System.out.print("What is the worker's base pay?\n\r> ");
number = inputBuffer.nextInt();
return number;
}
/*
* Calculate everything in DANGO DAI KAZOKOU
* @param jobRate --> the job rate
* @param merit --> the merit rating
* @param education --> the education rating
* @param basePay --> the base payment of the salary
* @param service --> the service rating
*/
public static double calcFinal( double jobRate, double merit, double education, double basePay, double service )
{
double finalPay; //the final salary to be outputted
double calcMoney; //the salary adjustment to be added
//to the thing
double finalRates; //the sum of all the rates
finalRates = ( jobRate + merit + education + service );
calcMoney = ( basePay * finalRates );
finalPay = ( basePay + calcMoney );
return finalPay;
}
/*
* finally return everything in a nice format :)
*
* @param jobRate --------> the specific job RATE
* @param merit ----------> the merit RATE
* @param education ------> the education RATE
* @param basePay --------> the base PAY RATE
* @param finalPay -------> the final payment already adjusted
* @param service --------> the service RATE
* @param jobWord --------> the job WORD
* @param meritWord ------> the merit WORD
* @param educationWord --> the education WORD
* @param serviceYears ---> the amount of years worked
*
*/
public static void printResults ( double jobRate, double merit, double education, double basePay, double finalPay, double service, String jobWord, String meritWord, String educationWord, int serviceYears )
{
//System.out.print( "\n\r" + jobRate + " " + merit + " " + education + " " + basePay + " " + finalPay + " " + service + " " + jobWord + " " + meritWord + " " + educationWord + " " + serviceYears);
System.out.print("\n\r---[FINAL RESULTS]-------------------------\n\r" + "Inital base pay: $" + basePay + "\n\r" + "Job Rate: " + jobRate + " (" + jobWord + ")\n\r" + "Service Rating: " + service + " (" + serviceYears + " Years)\n\r" + "Education: " + education + " (" + educationWord + ")\n\r" + "Merit Rating: " + merit + " (" + meritWord + ")\n\r" + "Final calculated payment: $" + finalPay + "\n\r" + "-------------------------------------[END]-\n\r" );
}
}