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

Second time posting this I really need this sooner then later please!!! This is

ID: 3713482 • Letter: S

Question

Second time posting this I really need this sooner then later please!!!

This is my code and I am having errors with it, i need the following changes done please.

1.I  should not prompt for tip amount, you calculate this based of the satisfaction selection.

2.If the user enters 40 you should prompt for overtime hours.

3. I need to review for correct capitalization and spacing. Format proper dollar.

4.When overtime is involved the regular pay calculation is incorrect. I need this corrected

5. I need to have a method for wage calculator and another for for calc_wages.

6. i have to classes i need the main method class removed to make my program run

public class PartB {

  

}

class MenuSystem{//main class named MenuSystem.

static Scanner console = new Scanner(System.in);//created an object for Scanner.

//check_pin method returns true if it is correct otherwise false.

public static boolean check_pin(String pinNum){

if(pinNum.compareTo("9999")==0)

return true;

return false;

}

//calc_wages method implemented as stated in question.

public static void calc_wages(){

System.out.print("Enter name :");

String name = console.nextLine();

System.out.print("Enter salary :");

double salary = console.nextDouble();

double regular_pay=0,overtime_pay=0,overtime=0;

System.out.print("How many hours have you worked in past week :");

double hours = console.nextDouble();

if(hours>40){

System.out.print("Enter the overtime hours you have worked :");

overtime = console.nextDouble();

overtime_pay = overtime*salary*1.5;

}

regular_pay = (hours-overtime)*salary;

System.out.println("Name :"+name);

System.out.println("hours worked :"+hours);

if(overtime>0)

System.out.println("Overtime hours worked :"+overtime);

System.out.println("Regular hours pay :$"+regular_pay);

if(overtime>0)

System.out.println("Overtime hours pay :$"+overtime_pay);

System.out.println("Total pay :$"+(regular_pay+overtime_pay));

}

//tip_calc method calculates the tip percentage and returns it.

public static double tip_calc(){

System.out.print("Enter amount paid for dinner :");

double dine_amount = console.nextDouble();

System.out.print("Enter tip amount :");

double tip = console.nextDouble();

double cents = (dine_amount+tip-(int)(dine_amount+tip))*100;

System.out.println("Total amount paid :$"+(int)(dine_amount+tip)+" "+(int)cents+"cents");

return tip/dine_amount*100;

}

//main method.

public static void main(String args[]){

System.out.print("Enter pin number :");

String pin = console.nextLine();

int option=3;

if(check_pin(pin)){

do{

System.out.print("----MENU---- ");

System.out.print("Enter 1 for Wage Calculator ");

System.out.print(" 2 for Tip Calculator ");

System.out.print(" 3 for Exit :");

option = console.nextInt();

if(option==1){

console.nextLine();

calc_wages();

}

else if(option==2){

double tip=tip_calc();

//prints the following messages based on the tip percentages.

if(tip>=3)

System.out.println("The customer highly satisfied");

else if(tip>0)

System.out.println("The customer moderately satisfied");

else System.out.println("The customer is not satisfied");

}

}while(option!=3);//loop continues iteration until user enters 3

}

else

System.out.print("Thank you for using our menu system");

}

}

Explanation / Answer

Code

import java.util.Scanner;

public class MenuSystem // 6. no use of Public class partB hence removed
{
//main class named MenuSystem.
static Scanner console = new Scanner(System.in);//created an object for Scanner.
//check_pin method returns true if it is correct otherwise false.
public static boolean check_pin(String pinNum)
{
  if(pinNum.compareTo("9999")==0)
   return true;
  return false;
}

//calc_wages method implemented as stated in question.
public static void calc_wages()       //5. wage calculator method
{
  System.out.print("Enter name :");
  String name = console.nextLine();
  System.out.print("Enter per hour salary :");
  double salary = console.nextDouble();
  double regular_pay=0,overtime_pay=0,overtime=0;
  System.out.print("How many hours have you worked in past week :");
  double hours = console.nextDouble();
  if(hours>=40){      // if user enters 40 it prompt overtime hours you just had to put '=' sign while comparing
   /* if you are taking 40 as mark for saying that they have worked overtime if they have done 40 hours
    * means the maximum hours a person can do without overtime is 39 hours
    * So, we will calculate overtime hours instead of asking them
    * asking the users their overtime is flawed as you have already asked the number of hours they have worked .
    */
   overtime=hours-39; //since 40 is the mark from which you are considering overtime.
   overtime_pay = overtime*salary*1.5;
  }
  regular_pay = (hours-overtime)*salary;
  System.out.println("Name :"+name);
  System.out.println("hours worked :"+hours);
  if(overtime>0)
  {
    System.out.println("Overtime hours worked :"+overtime);
    System.out.println("Overtime hours pay :$"+overtime_pay);
  }   
  System.out.println("Regular hours pay :$"+regular_pay);
  System.out.println("Total pay :$"+(regular_pay+overtime_pay));
}
//tip_calc method calculates the tip percentage and returns it.
public static double tip_calc()
{
  double tip=0;
  System.out.print("Enter amount paid for dinner :");
  double dine_amount = console.nextDouble();
  System.out.print("How much were you satisfied with the service");       // 1. Doesn't asks for tip calculation instead calculates on the basis of satisfaction
  System.out.print(" 1. Highly Satisfied ");
  System.out.print(" 2. Moderately Satisfied ");
  System.out.print(" 3. Not Satisfied at all ");
  int opt=console.nextInt();
  switch(opt)
  {
  case 1:
    tip=3.5;
    break;
  case 2:
    tip=1.2;
    break;
  case 3:
    tip=0;
    break;
  }
  
  double cents = (dine_amount+tip-(int)(dine_amount+tip))*100;
  System.out.println("Total amount paid :"+(int)(dine_amount+tip)+"$ and "+(int)cents+"cents");    //3. Dollar formatting
  return tip/dine_amount*100;
}


public static void main(String args[])
{
System.out.print("Enter pin number :");
String pin = console.nextLine();
int option=3;
if(check_pin(pin))
{
  do
  {
   System.out.print("----MENU---- ");
   System.out.println("Enter ");
   System.out.print(" 1 for Wage Calculator ");
   System.out.print(" 2 for Tip Calculator ");
   System.out.print(" 3 for Exit :");
   option = console.nextInt();
   if(option==1)
   {
    console.nextLine();
    calc_wages();
   }
   else if(option==2)
   {
    tip_calc();
   }
  }while(option!=3);//loop continues iteration until user enters 3
}
else
  System.out.print("You entered the wrong pin");
}

}

OUTPUT

Enter pin number :9999
----MENU----
Enter
1 for Wage Calculator
2 for Tip Calculator
3 for Exit :1
Enter name :chegg
Enter per hour salary :60
How many hours have you worked in past week :42
Name :chegg
hours worked :42.0
Overtime hours worked :3.0
Overtime hours pay :$270.0
Regular hours pay :$2340.0
Total pay :$2610.0.

Hope this solves your issues

Keep asking questions we will keep answering them.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote