Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package helloworld; import java.util.Scanner; public class PartA_Austin_Adams { public static void main(String[] args) { Scanner sc = new Scanner(System.in); validatePassword(sc); int choice; boolean quit =

package helloworld;

import java.util.Scanner;

public class PartA_Austin_Adams {

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::");

}

private static double[] getInput(){

double[] array = new double[12];

Scanner sc = new Scanner(System.in);

for(int i=0; i<12; i++){

System.out.print("Enter Railfall Value for Month ["+(i+1)+"] :");

array[i] = sc.nextDouble();

}

return array;

}

}

I need the psudecode for this program if possible

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

Step: 3

blur-text-image

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