Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

any help with this mainly part B part A has already been finished code for Part A: import java.util.Scanner; public class PartA { public static

image text in transcribed

image text in transcribed

any help with this mainly part B part A has already been finished

code for Part A:

import java.util.Scanner;

public class PartA {

public static Scanner sc = new Scanner(System.in);

public static int menu() {

int choice;

System.out.println(" 1) Wage Calculator 2)Tip Calculator 3)Exit");

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

choice = sc.nextInt();

return choice;

}

public static void main(String args[]) {

int pin = 9999;

String name; // name of the User

double hourlyPayRate, numberHours, regularWage, overtimePay, totalPay = 0.0, tip = 0.0;

String satisfaction = null;

System.out.print("Enter the PIN : ");

int userPin = sc.nextInt();

if(pin == userPin) {

while(true) {

int choice = menu();

switch(choice) {

case 1:

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

name = sc.next();

System.out.print("Enter your hourly pay rate: ");

hourlyPayRate = sc.nextDouble();

System.out.print("How many hours did you work last week? : ");

numberHours = sc.nextDouble();

if(numberHours > 40) {

regularWage = 40 * hourlyPayRate;

overtimePay = (numberHours - 40) * 1.5 * hourlyPayRate;

} else {

regularWage = numberHours * hourlyPayRate;

overtimePay = 0.0;

}

totalPay = regularWage + overtimePay;

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

if(overtimePay > 0) {

System.out.println("Regular hours worked : 40");

System.out.println("Regular hours Pay : " + regularWage);

System.out.println("Overtime hours worked : " + (numberHours - 40));

System.out.println("Overtime hours Pay : " + overtimePay);

} else {

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

System.out.println("Regular hours Pay : " + regularWage);

}

System.out.println("Total Pay : " + totalPay);

break;

case 2:

System.out.print("Tell me your expectation level"

+ " 1 = Totally Statisfied 2 = Satisfied 3 = Dissatisfied ");

int satisfactionLevel = sc.nextInt();

switch(satisfactionLevel) {

case 1:

tip = totalPay * 0.2;

satisfaction = "Totally Satisfied";

break;

case 2:

tip = totalPay * 0.15;

satisfaction = "Satisfied";

break;

case 3:

tip = totalPay * 0.1;

satisfaction = "Dissatisfied";

break;

default:

System.out.println("Not a valid satisfaction level!!!!");

}

System.out.println("Your tip is $" + tip + " ( " + satisfaction + ")");

break;

case 3:

System.out.println("Thank you for visiting :). Exiting......");

return;

}

}

} else {

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

}

}

}

CSCI 140/L. Java Project: Menu-Driven System Part A Write a menu-driven program that will give the user the three choices: 1) Wage calculator, 2) Tip Calculator, and 3) Exit. Class Name: PartA Password Access: For the user to gain access to the menu, they must enter a pin number (use pin 99 for this first program). You will prompt the user for the pin number. If the pin is correct, then display the menu. If the pin is incorrect, end the program with a message Thank you for using our menu system." 99 Wage Calculator: For the wage calculator, prompt for the name and hourly pay rate of an employee. Here the hourly pay rate is a floating-point number, such as $9.25. Then ask how many hours the employee worked in the past week. Be sure to accept fractional hours. Compute the pay. Any overtime work (over 40 hours per week) is paid at 150 percent of the regular wag (1.5 the hourly pay rate). Print the employee's name, regular hours worked, regular hours pay, overtime hours worked (do not show overtime hours, if there are none), overtime hours pay (do not show overtime pay if there is none), and total pay. [Do not prompt for overtime hours]) Tip Calculator: For the tip calculator, the tip is calculated based on the diner's satisfaction level. Ask for the diner's satisfaction level using these ratings: 1-Totally satisfied, 2-Satisfied 3-Dissatisfied. If the diner's choice is 1, calculate a 20 percent tip. If the diner's choice is 2, calculate a 15 percent tip. If the diner's choice is 3, calculate a 10 percent tip. Print the satisfaction level and tip in dollars and cents. [Format: "Your tip is $4.00 (Totally satisfied) Exit: The exit choice will display a statement that the program will end and thank the user for ing the program. [They must choose to exit the menu, not default out-it is a menu option] ur program should be complete and with correct convention (ie. Variable naming and declaration) and commenting (correct header with well-formed pseudocode). The obtain 50 o 100 points, your program must compile and run, You will obtain 30 points if your program runs correctly. You will obtain 20 points for all other convention and commenting (this includes file and class naming convention). All output should be properly formatted and user friendly

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

=+5. How would you rewrite the copy to make it more effective?

Answered: 1 week ago