Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

**The programming language is Java*** PART A: Write a menu-driven program that w

ID: 3853842 • Letter: #

Question

**The programming language is Java***

PART A: Write a menu-driven program that will give the user the three choices: 1) Pay Calculator, 2) Bonus Calculator, and 3) Exit.
Pay Calculator Prompt for the employee’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. 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 employee’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.
Bonus Calculator A company rewards salespeople for the number of sales over 5 and if the average sale is over $500. Prompt for the employee’s name, number of sales, and total sales amount. For every sale over 5 the employee is awarded $25. If the average sale is more than $500, employees are awarded 20% of the amount over $500 (e.g. the average is $750, the employee's would be awarded 20% of $250). Print the employee’s name, number of sales, . total sales amount, average sales amount, bonus on number of sales, bonus on average sale, and total bonus amount.
The exit choice will display a statement that the program will end and thank the user for using the program.
Your program should be complete and with correct convention and commenting. To obtain 50 of 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).

Adding Arrays and File Input/Output to our Part B menu-driven program that will give the user the following choices: Pay Calculator, Bonus Calculator, Wage Report, Bonus Report and Exit. Modification: Your program will now be able to store multiple records for calculating wages and tips. To do so, add the following: For the pay 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, so just add one entry and return to the menu. This builds on Part B so include that information and any new requirements listed below. [This will require a little thought to work with modification C below] For the bonus calculator: store each name and total bonus in a 2 dimensional array. Add a new menu item that will show a report in the console of all individuals whose pay you calculated. You will need to read the information from the file and format to make it easier to read on the screen with the employee's name listed first and each data element listed on a separate line along with a label. There should be two lined between each record. Add a menu item that will provide a listing of all earned bonus amounts sorted largest to smallest along with the name of the employee. At the end, include a total amount of all bonuses as well. For the exit option, ask the user if they are sure they want to exit. If they do not, return to the menu and continue per usual. If they want to continue, display the number of wages calculated and the number of groceries sold. Once you show these messages, then display a "Thank you message" for using the program. 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. **Remember to follow minimum requirements from Part B and make any necessary modifications accordingly. Your program should be complete and with correct convention and commenting. To obtain 50 of 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).

Explanation / Answer

import java.util.*;
import java.io.*;

public class TestClass {
   public static Scanner sc=new Scanner(System.in);
   public static String file="/home/java.txt";
   public static void main(String args[]) {
       while(true) {
           System.out.println("1) Pay Calculator, 2) Bonus Calculator, 3) Exit.");
           int x=sc.nextInt();
           if(x==1) {
               System.out.println("yes1");
               pay_calculator();
           } else if(x==2) {
               System.out.println("yes2");
               bonus_calculator();
           } else {
               break;
           }
       }
   }
   public static void pay_calculator() {
       System.out.println("Enter Employee name");
       String name=sc.next();
       System.out.println("Enter total sales");
       double sal=sc.nextDouble();
       System.out.println("Enter total hours");
       double hrs=sc.nextDouble();
       double dwage=9.25;
       double fhrs=40.5;
       double overpay=0.0, overhrs=0.0, regpay=0.0, reghrs=0.0;
       if(hrs>fhrs) {
           regpay=fhrs*9.25;
           overhrs=hrs-fhrs;
           overpay=overhrs*9.25*1.5;
           regpay=fhrs*9.25;
           String writeto=""+name+" "+hrs+" "+overhrs+" "+regpay+" "+overpay+" "+(regpay+overpay);
           System.out.println(name+" "+hrs+" "+overhrs+" "+regpay+" "+overpay+" "+(regpay+overpay));
           try {
               File.write(file, writeto.getBytes(), StandardOpenOption.APPEND);
           } catch (IOException e) {  
           }
       } else {
           regpay=hrs*9.25;
           String writeto=""+name+" "+hrs+" "+regpay+" "+regpay;
           System.out.println(name+" "+hrs+" "+regpay+" "+regpay);
           try {
               File.write(file, writeto.getBytes(), StandardOpenOption.APPEND);
           } catch (IOException e) {  
           }
       }
   }
   public static void bonus_calculator() {
       System.out.println("Enter Employee name");
       String name=sc.next();
       System.out.println("Enter total sales");
       int scount=sc.nextInt();
       System.out.println("Enter total amount");
       double totalamt=sc.nextDouble();
       int salediff=0;
       double avgamt=totalamt/scount;
       double bonussale=0.0, bonusavg=0.0;
       if(scount>5) {
           salediff=scount-5;
           bonussale=salediff*25;
       }
       if(avgamt>500) {
           bonusavg=(avgamt-500);
           bonusavg+=(bonusavg*20)/100;
       }
       String writeto=""+name+" "+scount+" "+totalamt+" "+avgamt+" "+bonussale+" "+bonusavg+" "+(bonussale+bonusavg);
       try {
           File.write(file, writeto.getBytes(), StandardOpenOption.APPEND);
       } catch (IOException e) {  
       }
       System.out.println(name+" "+scount+" "+totalamt+" "+avgamt+" "+bonussale+" "+bonusavg+" "+(bonussale+bonusavg));
   }
}