Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need the following changes made to my program please!! 1. Add commenting where its nesscerary 2.Password Access: Modification use a method named check_pin(String pinNum),

I need the following changes made to my program please!!

1. Add commenting where its nesscerary

2.Password Access: Modification use a method named check_pin(String pinNum), to determine if the user entered the correct pin.

3.CHANGE: The user can ONLY enter a maximum of 40 hours for regular pay. If the user has worked more than 40 hours, ask for the number of overtime hours.

4.CHANGE: Also, print the diners final total with the tip included (formatted, also in dollars and cents).

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

validatePassword(sc);

int choice; boolean quit = false;

while(!quit){

showMenu();

choice = sc.nextInt();

switch (choice) {

case 1:

calculateWages(sc);

break;

case 2:

calculateTip(sc);

break;

case 3:

quit=true;

break;

default:

System.out.println("Wrong input");

break;

}

}

sc.close();

}

private static void validatePassword(Scanner sc) {

int pin = 9999;

int p;

System.out.println("Please enter pin number:");

p= sc.nextInt();

if(pin != p){

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

System.exit(0);

}

}

private static void calculateTip(Scanner sc) {

int level;

System.out.println("Please enter satisfaction Level (1=Totally Satisfied, 2=Satisfied, 3=Dissatisfied):");

level = sc.nextInt();

double dinnerTotal;

System.out.println("Please enter your dinner total: ");

dinnerTotal = sc.nextDouble();

double tip=0;

if(level==1)

tip = (dinnerTotal/100.0d)*20.0;

if(level==2)

tip = (dinnerTotal/100.0d)*15.0;

if(level==3)

tip = (dinnerTotal/100.0d)*10.0;

System.out.print("Your Tip Amount is :"+tip);

if(level==1)

System.out.println("(Totaly Satisfied)");

if(level==2)

System.out.println("(Satisfied)");

if(level==3)

System.out.println("(Dissatisfied )");

System.out.println("Thank you for using the Tip Calculator! Have a great day!");

}

private static void calculateWages(Scanner sc) {

String name;

double hPay;

int hours;

System.out.println("Please enter your name:");

name = sc.next();

System.out.println("Please enter your hourly wage:");

hPay = sc.nextDouble();

System.out.println("Please enter your hours worked:");

hours = sc.nextInt();

double regPay = 0.0;

if(hours>40)

regPay = (double)40*hPay;

else

regPay = (double)hours*hPay;

double overPay;

if(hours>40)

overPay = (double)(hours-40)*(hPay+(hPay/2.0d));

else

overPay = 0.0d;

int overH = 0;

if(hours>40){

overH = hours-40;

hours = 40;

}

System.out.println("Hello "+name);

System.out.println("Your regular hours worked are "+(hours));

if(overH>0)

System.out.println("Your regular hours worked are "+(overH));

System.out.println("Your regular pay: "+regPay);

if(overH>0)

System.out.println("Your overtime pay: "+overPay);

System.out.println("Your total pay: "+(regPay+regPay));

System.out.println("Thank you for using the Wage Calculator "+name+"! Have a great day! ");

}

private static void showMenu() {

System.out.println("[1] Wage calculator.");

System.out.println("[2] Tip Calculator.");

System.out.println("[3] Exit.");

System.out.println("Enter your Choice::");

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

10. Describe the relationship between communication and power.

Answered: 1 week ago