Menu

[Solved]Java Code Make Changes Following Java Code Directions Import Javatextnumberformat Import J Q37295398

CSCI 140/L Java Project: Menu-Driven System Part C Adding Arrays and File Input/Output to our Part B menu-driven program that

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 num

JAVA Code (make changes to the following java codebelow) Directions above

import java.text.NumberFormat;
import java.util.Locale;
import java.util.Scanner;

public class PartB {

   public static void main(String[] args) {

       Scanner sc = newScanner(System.in);
       // Password AccessModification
       System.out.println(“Please enterpin number:”);
       String pin= sc.nextLine();
       check_pin(pin);

       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;
                  System.out.println(“GroceryDiscount to be implemented later”);
              break;

           case 4:

              quit=true;

              break;

           default:

              System.out.println(“Wrong input”);

              break;

           }

       }

       sc.close();
   }
//Password Modification
   private static void check_pin(String pinNum) {

       int pin = 9999;     

       if(pin !=Integer.parseInt(pinNum)){

          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 entersatisfaction Level (1=Totally Satisfied, 2=Satisfied,3=Dissatisfied):”);

       level = sc.nextInt();

       double dinnerTotal;

       System.out.println(“Please enteryour dinner total: “);

       dinnerTotal =sc.nextDouble();

       double tip=0d;

       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 TipAmount is :”+tip);

       if(level==1)

          System.out.println(“(Totaly Stisfied)”);

       if(level==2)

          System.out.println(“(Stisfied)”);

       if(level==3)

          System.out.println(“(Dissatisfied Stisfied)”);
      
       System.out.println(” Do you want togive Personal Tip : Yes/No” );
       String result = sc.next();
      if(result.equalsIgnoreCase(“Yes”))
       {
          System.out.println(” Please Enter Tip Amount:” );
           double extraTip= sc.nextDouble();
           dinnerTotal +=extraTip;
       }

      
       dinnerTotal += tip;
      
       NumberFormat formatter =NumberFormat.getCurrencyInstance(Locale.US);
      
       System.out.println(“Your finaltotal is “+formatter.format(dinnerTotal) );

       System.out.println(“nThank youfor using the Tip Calculator! Have a great day!n”); }

   //Modified calculateWages
   private static void calculateWages(Scanner sc) {

       String name;

       double hourPay;

       double hours;

       System.out.println(“Please enteryour name:”);
       name = sc.next();

       System.out.println(“Please enteryour hourly wage:”);

       hourPay = sc.nextDouble();

       System.out.println(“Please enteryour hours worked:”);

       hours = sc.nextDouble();
       double overTime = 0;

       if(hours>40)
       {
           hours =40;
          System.out.println(” You can enter max 40 hrs as regular Pay.nPlease enter overtime hours here:”);
           overTime =sc.nextDouble();
       }

       double regularPay = calc_wages(hours,hourPay);

       double overPay =overTime*(hourPay*1.5);

       System.out.println(“Hello”+name);

       System.out.println(“Your regularhours worked are “+hours);
      
       if(overTime>0)
          System.out.println(“Your overtime hours worked are”+overTime);
      
       System.out.println(“Your regularpay: “+regularPay);
      
       if(overTime>0)
          System.out.println(“Your overtime pay: “+overPay);

       System.out.println(“Your totalpay: “+(regularPay+overPay));

       System.out.println(“nThank youfor using the Wage Calculator “+name+”! Have a great day!n”);
   }
  
   private static double calc_wages(double hours, doublehours_rate)
   {
       return hours*hours_rate;
   }
   //Modified showMenu
   private static void showMenu() {

       System.out.println(“n[1] Wagecalculator.”);

       System.out.println(“[2] TipCalculator.”);

       System.out.println(“[3] GroceryDiscount.”);
      
       System.out.println(“[4]Exit.”);

       System.out.println(“Enter yourChoice:”);

   }

   private static double[] getInput(){ double[] array= new double[12];

   Scanner sc = new Scanner(System.in);

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

       array[i] = sc.nextDouble();

   }

   return array;

   }

}

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) Grocery Discount, 4) Wages Report, 5) Tips Report, and 6) 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 their password is not in the array tell them it is not, 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. Implement the grocery discount. See requirement below E. Add a new menu item that will show a report of all individuals whose wages you calculated. F. 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) G. 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 to exit, 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. H. 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] Grocery Discount Requirements: [Modification] A supermarket awards coupons depending on how much a customer spends on groceries. For example, if you spend $50, you will get a coupon worth eight percent of the amount. Write the code to calculate and print the value of the coupon a person can receive based on groceries purchased. The output will have the same format as the tip calculator. The percent used to calculate the coupon is as follows: less than $10, no coupon; from $10 to $60, 8 percent; more than $60 to $150, 10 percent; more than $150 to $210, 12 percent; and more than $210, 14 percent. 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. To obtain 50 of 100 points, your program must compile and run with the correct code requirements. You will obtain up to 30 points if your program runs correctly and code structure meets requirements. You will obtain up to 20 points for all other convention and commenting (this includes file and class naming convention) Pseudocode must match code Once complete, you will submit your java file using the program PartC link in Moodle Show transcribed image text 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) Grocery Discount, 4) Wages Report, 5) Tips Report, and 6) 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 their password is not in the array tell them it is not, 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. Implement the grocery discount. See requirement below E. Add a new menu item that will show a report of all individuals whose wages you calculated. F. 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) G. 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 to exit, 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. H. 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] Grocery Discount Requirements: [Modification] A supermarket awards coupons depending on how much a customer spends on groceries. For example, if you spend $50, you will get a coupon worth eight percent of the amount. Write the code to calculate and print the value of the coupon a person can receive based on groceries purchased. The output will have the same format as the tip calculator. The percent used to calculate the coupon is as follows: less than $10, no coupon; from $10 to $60, 8 percent; more than $60 to $150, 10 percent; more than $150 to $210, 12 percent; and more than $210, 14 percent. 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. To obtain 50 of 100 points, your program must compile and run with the correct code requirements. You will obtain up to 30 points if your program runs correctly and code structure meets requirements. You will obtain up to 20 points for all other convention and commenting (this includes file and class naming convention) Pseudocode must match code Once complete, you will submit your java file using the program PartC link in Moodle

Expert Answer


Answer to JAVA Code (make changes to the following java code below) Directions above import java.text.NumberFormat; import java.ut… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *