Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. A program that will calculate and print the total pay for an employee who get

ID: 3802410 • Letter: 1

Question

1. A program that will calculate and print the total pay for an employee who gets paid the normal rate for each hour less or equal to 40, and 1.5 times the normal rate for each hour over 40 as follows:

Input: hours = getHoursWorked();

Processing: calculate the gross pay by calling a value returning function from main() named: CalcGross

Output: value obtained from CalcGross and printed in main().

2. A program will calculate and print the miles per gallon as follows:

Input in main(): miles = GetMiles():

gallons = GetNumGallons():

Processing: calculate the miles per gallon by calling a value returning function from main() named: CalcMpg

output: Value returned from CalcMpg and printed in main()

Explanation / Answer

/*
Here business logic for some methods have not been provided.
So that It's assumed that those methods have already been implemented.
Such methods are
getHoursWorked(),getMiles(),getGallons()
*/


public class NewClass {
  
   public double CalcGross(double basicPay){
       double gross=0.0;
       int hours=getHoursWorked();
      
       if(hours<=40)
           gross=basicPay*hours;
      
       else
           gross=basicPay*hours*1.5;
       return gross;
   }
  
   public double calcMpg(){
       double gallon=getNumGallons();
       double miles=getMiles();
      
       return miles/gallon;
      
   }
  
   public static void main(String a[]){
       NewClass nc=new NewClass();
      
       System.out.println("Gross: "+nc.CalcGross(59999.00));
       System.out.println(nc.calcMpg());
   }

}