2. Space Inc. will give a quarterly and annual bonus to its employees only if th
ID: 3731946 • Letter: 2
Question
2. Space Inc. will give a quarterly and annual bonus to its employees only if the savings of the quarter and/or the year are greater than or equal to quarterly minimum (monthly commitment x 3) and/or the annual minimum (monthly commitment x 12) amount, respectively. The quarterly bonus is 3% of eligible quarterly savings, and the annual bonus is 5% of annual savings if eligible. If the annual savings exceeds the committed amount by at least 25%, Space Inc. matches the additional savings (25% or above) as part of the annual bonus. I. An employee has committed to save $2000 per month. Her quarterly savings are as follows: Q1 – $5000, Q2 – $7000, Q3 – $4000, and Q4 – $8000. II. Another employee has committed to save $3000 per month. His quarterly savings are as follows: Q1 – $6000, Q2 – $9000, Q3 – $10000, and Q4 – $17000. Write a program to compute the total bonus amount earned by these two employees in the year.
Explanation / Answer
import java.util.*;
import java.lang.*;
import java.io.*;
class Chegg
{
public void compute1()
{
int quarterlySavingCom=2000*3;//It stores the committed quarterly saving of Employee1
int yearlySavingCom=2000*12;//It stores the committed yearly saving of Employee1
int a[]={5000,7000,4000,8000};//It stores the 4 actual quarterly saving in a year
int yearlySaving=0;//It will add all the actual quarterly saving and store the actual yearly Saving
double totalBonus=0;
for(int i=0;i<4;i++)
{
yearlySaving+=a[i];//Adding all the quarterly amount in a year
if(a[i]>=quarterlySavingCom)//Checking if the actual quarterly amount is greater than the committed quarterly amount
{
double bonusQuarterly=0.03*a[i];//It compute and stores the quarterly bonus,if eligible
totalBonus+=bonusQuarterly;
}
}
if(yearlySaving>=yearlySavingCom)
{
double bonusYearly=0.05*yearlySaving;//It compute and stores the yearly bonus,if eligible
totalBonus+=bonusYearly;
if((yearlySaving-yearlySavingCom)>=0.25*yearlySavingCom)//Checking if the yearly saving exceeds the committed yearly amount by 25% or not
totalBonus+=yearlySaving-yearlySavingCom;//Adding to the bonus,if the yearly saving exceeds the committed yearly amount by 25%
}
System.out.println("Total Bonus for Employee 1 : "+totalBonus);
}
public void compute2()
{
int quarterlySavingCom=3000*3;//It stores the committed quarterly saving of Employee2
int yearlySavingCom=3000*12;//It stores the committed yearly saving of Employee2
int a[]={6000,9000,10000,17000};//It stores the 4 actual quarterly saving in a year
int yearlySaving=0;//It will add all the actual quarterly saving and store the actual yearly Saving
double totalBonus=0;
for(int i=0;i<4;i++)
{
yearlySaving+=a[i];//Adding all the quarterly amount in a year
if(a[i]>=quarterlySavingCom)//Checking if the actual quarterly amount is greater than the committed quarterly amount
{
double bonusQuarterly=0.03*a[i];//It compute and stores the quarterly bonus,if eligible
totalBonus+=bonusQuarterly;
}
}
if(yearlySaving>=yearlySavingCom)
{
double bonusYearly=0.05*yearlySaving;//It compute and stores the yearly bonus,if eligible
totalBonus+=bonusYearly;
if((yearlySaving-yearlySavingCom)>=0.25*yearlySavingCom)//Checking if the yearly saving exceeds the committed yearly amount by 25% or not
totalBonus+=yearlySaving-yearlySavingCom;//Adding to the bonus,if the yearly saving exceeds the committed yearly amount by 25%
}
System.out.println("Total Bonus for Employee 2 : "+totalBonus);
}
public static void main (String[] args) throws java.lang.Exception
{
Chegg ob=new Chegg();
ob.compute1();//This function compute the bonus for Employee1
ob.compute2();//This function compute the bonus for Employee2
}
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.