Java Programming Really need help with this assignment! I was able to complete P
ID: 3713622 • Letter: J
Question
Java Programming
Really need help with this assignment! I was able to complete Parts A and B without help. But this one has me stumped. Please HELP!
CSCI 140/L Java Project: Menu-Driven System Part C Adding Arrays and File Input/Output to our Part B menu-driven program that will give the user the following choices: 1) Wage calculator, 2) Tip calculator, 3) Wages Report, 4) Tips Report, and 5) Exit. Modification: Your program will now be able to store multiple inputs for calculating wages and tips. To do so, add the following: A. For the password access: create an array to store passwords (no more than 5 for testing). When the user attempts to login, if there password is not in the array tell them and then allow them to store a password and login again B. For the wage calculator: after gathering the requested information and calculating the pay, store the individual's information to a file (with labels) in a single line. You cannot loop within the task; you must collect one entry and return to the menu. This information includes the previous information from Part B and any new requirements listed below. [This will require a little thought to work with modification C below] C. For the tip calculator: store each tip amount that is calculated in an array (name it tips) and store each total dinner bill (with tip) in a separate array (name it dinners) D. Add a new menu item that will show a report of all individuals whose wages you calculated. E. Add a menu item that will provide the total tips collected (in dollars and cents) and the total dollar amount of dinners sold (in dollars and cents) F. For the exit option, ask the user if they are sure they want to really exit or login using a different pin number. If they do not really want to exit, return to the menu and continue per usual. If they want to exit and login using a different pin number, allow them to do so and continue per usual If they want to continue, display the number of wages calculated and the number of dinners sold. Once you show these messages, then display a Thank you message" for using the program. G. All boundaries should be tested. This means a user should not be able to enter negative numbers for any input (input validation) or values outside of the bounds of requirements [See changes in sections below]. **Remember to follow minimum requirements from Part B and make modifications accordingly [this includes calling methods from the menu and other methods] Wage Calculator Requirements: For the wage calculator, prompt for the user's name and salary of an employee. Here the salary will denote an hourly wage, such as $9.25. Then ask how many hours the employee worked in the past week. Be sure to accept fractional hours. The user can ONLY enter values between 0 (zero) and a maximum of 40 hours for regular pay. If the user has worked more than 40 hours, ask for the number of overtime hours. Compute the pay. Any overtime work (over 40 hours per week) is paid at 150 percent of the regular wage (1.5 the overtime pay). Print the user's name,Explanation / Answer
Solution:
Explanation : The below program dispalys a menu option of calculating wags of an employee and calculating tips and shows customer satisfaction feedback in a restaurants. It also show a report of tips at the end of the day.
I updated the code with wages Report. Please check.
package chegg1;
import java.util.ArrayList;
import java.util.Scanner;
public class WageCalculator {
static Scanner scan = new Scanner(System.in);
static double tipsRep = 0.0;
static double dinnerRep = 0.0;
static String[] wagesRep = new String[5];
static int z=0;
public static double wageCalc()
{
String userName = null;
double salary = 0.0;
double hoursWorked = 0.0;
double ohoursWorked = 0.0;
double regularHrPay = 0.0;
double overTimePay = 0.0;
double totalPay = 0.0;
System.out.println("Enter the Employee Name");
userName = scan.next();
System.out.println("Enter the No.of Hours Worked in Last Week");
hoursWorked = scan.nextDouble();
System.out.println("Enter the No.of OverTime Hours Worked in Last Week");
ohoursWorked = scan.nextDouble();
regularHrPay = hoursWorked * 15;
if(ohoursWorked > 1)
{
overTimePay = ohoursWorked * 20;
}
totalPay = regularHrPay + overTimePay;
String s=null;
if(ohoursWorked > 1)
{
s = "UserName :"+userName+", Hourly Pay : $15"+", Hours Worked :"+hoursWorked+", OverTime Hours Worked :"+ohoursWorked+", Regular Hours Pay : $"+regularHrPay+", OverTime Hours Pay : $"+overTimePay+", Gross Pay : $"+totalPay;
System.out.println("UserName :"+userName);
System.out.println("Hourly Pay : $15");
System.out.println("Hours Worked :"+hoursWorked);
System.out.println("OverTime Hours Worked :"+ohoursWorked);
System.out.println("Regular Hours Pay : $"+regularHrPay);
System.out.println("OverTime Hours Pay : $"+overTimePay);
System.out.println("Gross Pay : $"+totalPay);
}else
{
s = "UserName :"+userName+", Hourly Pay : $15"+", Hours Worked :"+hoursWorked+", Regular Hours Pay : $"+regularHrPay+", Gross Pay : $"+totalPay;
System.out.println("UserName :"+userName);
System.out.println("Hourly Pay : $15");
System.out.println("Hours Worked :"+hoursWorked);
System.out.println("Regular Hours Pay :$"+regularHrPay);
System.out.println("Gross Pay :$"+totalPay);
}
wagesRep[z] = s;
z = z +1;
System.out.println();
return totalPay;
}
public static void tipcalc()
{
System.out.println("Enter satisfaction level number(1=totally satisfied, 2=satisfied, 3=dissatisfied);");
double satisfactionLevel = scan.nextDouble();
System.out.println("Please enter you dinner total: ");
double dinnerPay = scan.nextDouble();
double tip = 0;
String level = "";
if(satisfactionLevel == 1) {
tip = dinnerPay * 0.2;
level = "Totally Satisfied";}
else if(satisfactionLevel == 2) {
tip = dinnerPay *0.15;
level = "Satisfied";}
else if(satisfactionLevel == 3) {
tip = dinnerPay *0.1;
level = "Dissatisfied";}
tipsRep = tipsRep + tip;
dinnerRep = dinnerRep+dinnerPay;
System.out.println("Your tip amount is : $"+tip+" and the customer was "+level);
System.out.println("Total Amount paid including tip is : $"+(dinnerPay+dinnerPay*.2));
System.out.println("Thanku! Have a greate Day");
System.out.println();
}
public static int showMenu()
{
int option=0;
System.out.println("1. Wage Calculator");
System.out.println("2. Tip Calculator");
System.out.println("3. Tip Report ");
System.out.println("4. Wage Report ");
System.out.println("5. Exit");
System.out.println("Please Enter your choice :");
option = scan.nextInt();
return option;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
int menuOption = showMenu();
while(true)
{
switch(menuOption)
{
case 1: wageCalc();
break;
case 2: tipcalc();
break;
case 3:
System.out.println("******* Tips Report ***************");
System.out.println("The total tips for the Night are : $"+tipsRep);
System.out.println("The total Dinners sold are : $"+dinnerRep);
System.out.println();
break;
case 4:
System.out.println("******* Wages Report ***************");
for(int i=0;i<wagesRep.length;i++)
{
if(wagesRep[i] != null)
System.out.println(wagesRep[i]);
else
System.out.println("");}
break;
case 5:
System.exit(0);
default :
System.out.println("Please enter valid input again : ");
}
menuOption = showMenu();
}
} catch (Exception e) {
// TODO: handle exception
System.out.println("Program has encountered a probealm:");
}finally
{
scan.close();
}
}//main close
}//class close
--------------------------------------------------------------------------------------------------------------
Output :
1. Wage Calculator
2. Tip Calculator
3. Tip Report
4. Wage Report
5. Exit
Please Enter your choice :
1
Enter the Employee Name
omka
Enter the No.of Hours Worked in Last Week
20
Enter the No.of OverTime Hours Worked in Last Week
20
UserName :omka
Hourly Pay : $15
Hours Worked :20.0
OverTime Hours Worked :20.0
Regular Hours Pay : $300.0
OverTime Hours Pay : $400.0
Gross Pay : $700.0
1. Wage Calculator
2. Tip Calculator
3. Tip Report
4. Wage Report
5. Exit
Please Enter your choice :
1
Enter the Employee Name
20
Enter the No.of Hours Worked in Last Week
25
Enter the No.of OverTime Hours Worked in Last Week
23
UserName :20
Hourly Pay : $15
Hours Worked :25.0
OverTime Hours Worked :23.0
Regular Hours Pay : $375.0
OverTime Hours Pay : $460.0
Gross Pay : $835.0
1. Wage Calculator
2. Tip Calculator
3. Tip Report
4. Wage Report
5. Exit
Please Enter your choice :
4
******* Wages Report ***************
UserName :omka, Hourly Pay : $15, Hours Worked :20.0, OverTime Hours Worked :20.0, Regular Hours Pay : $300.0, OverTime Hours Pay : $400.0, Gross Pay : $700.0
UserName :20, Hourly Pay : $15, Hours Worked :25.0, OverTime Hours Worked :23.0, Regular Hours Pay : $375.0, OverTime Hours Pay : $460.0, Gross Pay : $835.0
null
null
null
1. Wage Calculator
2. Tip Calculator
3. Tip Report
4. Wage Report
5. Exit
Please Enter your choice :
5
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.