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 and more. To do so, add the following:

A. For the password access: create an array to store pins (no more than 5, for testing). When the user attempts to login, if their pin is not in the array tell them it is not, and then allow them to store a pin and login again. Be sure to store 9999 as the first pin number [index zero].

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.

Grocery Discount Requirements: 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.

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).

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

public class PartB {
static Scanner in = new Scanner(;
static ArrayList<String> pins = new ArrayList<String>();
static ArrayList<Double> dinners = new ArrayList<Double>();
static ArrayList<Double> tips = new ArrayList<Double>();
static int count = 0;

public static void main(String[] args) throws FileNotFoundException {
// post variable
pins.add(0, "9999");
String pinGuessed = "";

// print statement
System.out.println("Enter pin: ");
pinGuessed =;

public static boolean find(ArrayList<String> arr, String s) {
boolean k = false;
for(int i = 0; i < arr.size(); i++) {
k = true;
return k;

public static void check_pin(String pinNum) throws FileNotFoundException {
if(find(pins, pinNum)) {
System.out.println("Access granted.");
else {
System.out.println("New pin detected");
if(pins.size() <= 4) {

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats