Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the code to add onto. Thank you! Import java.util.Scanner; public class PartA { public static void main(String[] args) { // TODO Auto-generated method

image text in transcribedimage text in transcribed

This is the code to add onto. Thank you!

Import java.util.Scanner;

public class PartA {

public static void main(String[] args) {

// TODO Auto-generated method stub

//creaing object to the scanner class

Scanner sc = new Scanner(System.in);

//asking pin to the user

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

int pin = sc.nextInt();

//checking the pin

if(pin==9999) {

//displaying the calculator menu

System.out.println("Calculator Menu");

System.out.println("1.Wage Calculator");

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

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

System.out.print(" Please Enter your choice:");

int choice = sc.nextInt();

//functinality of wage calculator

if(choice==1) {

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

String name = sc.nextLine();

name = sc.nextLine();

System.out.print("Please Enter your hourly wage:");

float hourWage = sc.nextFloat();

System.out.print("Please Enter your hours worked:");

int workedHours = sc.nextInt();

int regularHours,overHours;

float regularPay,overPay,totalPay;

if(workedHours>40) {

regularHours = 40;

overHours = workedHours - 40;

regularPay = regularHours * hourWage;

overPay = overHours * (float)1.5 * hourWage;

totalPay = regularPay + overPay ;

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

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

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

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

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

System.out.println("Your totla pay: "+totalPay);

}

else {

regularHours = workedHours;

regularPay = regularHours * hourWage;

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

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

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

}

System.out.println("Thank you for using the wage calculator "+name+"!");

System.out.println("Have a great day!");

}

//funcitonality of tip calculator

else if(choice==2) {

System.out.print("Please Enter Satisfactin Level(1=Totally Satisfied, 2=Satisfied, 3=Dissatisfied)");

int level = sc.nextInt();

System.out.print("Please Enter your dinner total:");

float dinnerTotal = sc.nextFloat();

if(level==1) {

System.out.println("Your tip amount is $"+(dinnerTotal*0.20)+"(Total Satisfied)");

System.out.println("Thank you for using tip calculator");

System.out.println("Have a great day!");

}

else if(level==2) {

System.out.println("Your tip amount is $"+(dinnerTotal*0.15)+"(Total Satisfied)");

}

else if(level==3) {

System.out.println("Your tip amount is $"+(dinnerTotal*0.10)+"(Total Satisfied)");

}

else {

System.out.println("Invalid choice...");

}

}

else if(choice == 3) {

System.out.println("Thanks for using this program....");

}

else {

System.out.println("Invalid choice");

}

}

else {

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

}

}

}

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

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students also viewed these Databases questions

Question

9. Describe the characteristics of power.

Answered: 1 week ago