Question
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started