I need This Answered ASAP please and thank you i will rate well I have posted my
ID: 3713676 • Letter: I
Question
I need This Answered ASAP please and thank you i will rate well
I have posted my program below, I need the following adjustments made to it please. I gave all the information you could possibly need thats why there's so much information.
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, hours worked, overtime hours worked (do not show overtime, if there is none), regular hours pay, overtime hours pay (do not show overtime pay if there is none), and total pay. [Change] Tip Calculator Requirements: For the tip calculator, the tip is calculated based on the diner’s satisfaction level. The main function from part B also prints the diner’s final total with the tip included. Exit Requirements: The exit choice will display a statement that the program will end and thank the user for using the program. [Change] Wages Report Requirements: [Modification] Read the individual’s information from the file and display for the user. The output should be formatted and readable (hint: this should be done when storing the information). [You will not be able to use the same Writer class, do a little research] Tip and Diner’s Report Requirement: [Modification] Calculate the total tips from the tips arrays and display for the user (in dollars and cents). Calculate the total dinners sold (remember this includes tip) and display for the user (in dollars and cents). Your program should be complete and with correct convention and commenting
import java.util.Scanner;
public class PartB
{
static Scanner console = new Scanner(System.in);
//check_pin method returns true if it is correct otherwise false.
public static boolean check_pin(String pinNum)
{
if(pinNum.compareTo("9999")==0)
return true;
return false;
}
public static void calc_wages()
{
System.out.print("Enter name :");
String name = console.nextLine();
System.out.print("Enter per hour salary :");
double salary = console.nextDouble();
double regular_pay=0,overtime_pay=0,overtime=0;
System.out.print("How many hours have you worked in past week :");
double hours = console.nextDouble();
if(hours>=40){
overtime=hours-39;
overtime_pay = overtime*salary*1.5;
}
regular_pay = (hours-overtime)*salary;
System.out.println("Name :"+name);
System.out.println("hours worked :"+hours);
if(overtime>0)
{
System.out.println("Overtime hours worked :"+overtime);
System.out.println("Overtime hours pay :$"+overtime_pay);
}
System.out.println("Regular hours pay :$"+regular_pay);
System.out.println("Total pay :$"+(regular_pay+overtime_pay));
}
public static double tip_calc()
{
double tip=0;
System.out.print("Enter amount paid for dinner :");
double dine_amount = console.nextDouble();
System.out.print("How much were you satisfied with the service");
System.out.print(" 1. Highly Satisfied ");
System.out.print(" 2. Moderately Satisfied ");
System.out.print(" 3. Not Satisfied at all ");
int opt=console.nextInt();
switch(opt)
{
case 1:
tip=3.5;
break;
case 2:
tip=1.2;
break;
case 3:
tip=0;
break;
}
double cents = (dine_amount+tip-(int)(dine_amount+tip))*100;
System.out.println("Total amount paid :"+(int)(dine_amount+tip)+"$ and "+(int)cents+"cents");
return tip/dine_amount*100;
}
public static void main(String args[])
{
System.out.print("Enter pin number :");
String pin = console.nextLine();
int option=3;
if(check_pin(pin))
{
do
{
System.out.print("----MENU---- ");
System.out.println("Enter ");
System.out.print(" 1 for Wage Calculator ");
System.out.print(" 2 for Tip Calculator ");
System.out.print(" 3 for Exit :");
option = console.nextInt();
if(option==1)
{
console.nextLine();
calc_wages();
}
else if(option==2)
{
tip_calc();
}
}while(option!=3);//loop continues iteration until user enters 3
}
else
System.out.print("You entered the wrong pin");
}
}
Explanation / Answer
Hi Dear,
Please find my implementation.
Output:
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.