/**@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * File : SalonSol * Date : Updated with constants Jun 8, 2010 * @author : mr Hanley * Purpose : Solution to the Salon Problem @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ import java.util.Scanner; public class SalonSol { /*This class manages a hair salon. Global variables are used to keep track of dailyRevues (total $ coming in), dailyTax (total tax amount) and the number of hair cuts, permanents and colorings Also, the number of customers who have been serviced is to be kept track of A daily report is to be printed which gives the total number of customers, the total number of hair cuts, permanents and colorings. Also, the total amount of revenue (money taken in) and tax needs to be printed in the daily report. Finally, the average amount of money spent by each customer should be calculated and printed in the report. If the store brings in $650 or more, then the store manager receives 5% of the daily total revenue as a bonus. You should include the store manager bonus in your report and subtract it from the total revnue to give the net revenue for the day. Feel free to add additional variables and methods as you deem necessary See example report*/ //Globals Scanner input = new Scanner(System.in); double hairCuts, permanents, colorings; //The number of each of these services double customers; //total number of customers double dailyRev, dailyTax, dailyNet; //the daily revenue(money taken in DOES // NOT INCLUDE TAX), //the daily tax and the daily net revenue (the revenue - //any manager bonus double bonus; //money due the manager if certain conditions are met //Constants to be finished by the student final double COSTHC = 20; //Cost of HairCut final double COSTPERM = 50; //Cost of Permanent final double COSTCOLORING = 60; //Cost of Coloring //Added variable for nystate tax final double taxRate = .07; double tax; //tax for this sale double charge; //charge for this service public SalonSol() { menu(); } public void menu() { //preconditions: none //postconditions: the correct method is called depending on the user's //input, totalValues are updated appropriately int choice; do { System.out.println("---------MENU---------"); System.out.println("1 = Reset Daily Totals"); System.out.println("2 = Haircut Only"); System.out.println("3 = Permanent Only"); System.out.println("4 = Coloring Only"); System.out.println("5 = Haircut and Coloring"); System.out.println("6 = Haircut and Permanent"); System.out.println("7 = Permanent and Coloring"); System.out.println("8 = Haircut, Permanent and Coloring"); System.out.println("9 = Print Daily Report"); System.out.println("10 = Exit"); choice = input.nextInt(); if (choice == 10) { System.exit(0); } //FINISH THE METHOD MENU if (choice == 1) { resetTotals(); } if (choice == 2) { //haircut only customers++; hairCuts++; tax = COSTHC * taxRate; dailyRev += COSTHC; dailyTax += tax; double total = COSTHC + tax; System.out.println("Haircuit"); System.out.println("Charge :" + COSTHC); System.out.println("Tax :" + tax); System.out.println("Total :" + total); } if (choice == 3) { //permanent only customers++; permanents++; tax = COSTPERM * taxRate; dailyRev += COSTPERM; dailyTax += tax; double total = COSTPERM + tax; System.out.println("Perm"); System.out.println("Charge :" + COSTPERM); System.out.println("Tax :" + tax); System.out.println("Total :" + total); } if (choice == 4) { //coloring only customers++; colorings++; tax = COSTCOLORING * taxRate; dailyRev += charge; dailyTax += tax; double total = COSTCOLORING + tax; System.out.println("Coloring"); System.out.println("Charge :" + COSTCOLORING); System.out.println("Tax :" + tax); System.out.println("Total :" + total); } if (choice == 5) { //haircut and coloring customers++; hairCuts++; colorings++; double charge = (COSTCOLORING + COSTHC)*.85; //discount of 15% tax = charge * taxRate; dailyRev += charge; dailyTax += tax; double total = charge + tax; System.out.println("Haircut+Coloring"); System.out.println("Charge :" + charge); System.out.println("Tax :" + tax); System.out.println("Total :" + total); } if (choice == 6) { //haircut and permanent customers++; hairCuts++; permanents++; double charge = (COSTPERM + COSTHC)*.85; //discount of 15% tax = charge * taxRate; dailyRev += charge; dailyTax += tax; double total = charge + tax; System.out.println("Haircut+Perm"); System.out.println("Charge :" + charge); System.out.println("Tax :" + tax); System.out.println("Total :" + total); } if (choice == 7) { //permanent and coloring customers++; permanents++; colorings++; double charge = (COSTPERM + COSTCOLORING)*.85; //discount of 15% tax = charge * taxRate; dailyRev += charge; dailyTax += tax; double total = charge + tax; System.out.println("Perm+Coloring"); System.out.println("Charge :" + charge); System.out.println("Tax :" + tax); System.out.println("Total :" + total); } if (choice == 8) { //haircut,coloring and permanent System.out.println("Haircut+Perm+Coloring"); customers++; hairCuts++; colorings++; permanents++; double charge = (COSTPERM + COSTHC + COSTCOLORING)*.85; //discount of 15% tax = charge * taxRate; dailyRev += charge; dailyTax += tax; double total = charge + tax; System.out.println("Haircut+Perm+Coloring"); System.out.println("Charge :" + charge); System.out.println("Tax :" + tax); System.out.println("Total :" + total); } if (choice == 9) { printReport(); } //Print Stuff to the user if they chose a service /* Commented out as this was more efficient but confusing if (choice >= 2 && choice <= 8) { System.out.println("Charge: $" + charge); System.out.println("Tax: $" + tax); double total = charge + tax; System.out.println("Total: $" + total); } */ } while (true); //Keeps running an infinite loop } //close menu /** postconditions:all relevant values set to 0 */ public void resetTotals() { hairCuts = permanents = colorings = 0; //The number of each of these services customers = dailyRev = dailyTax = dailyNet = bonus = 0; } public void printReport() /** Outputs daily report like example on attached page */ { //test to avoid divide by zero problem! if (customers == 0) { return; //just get out of here! } System.out.println("Daily Report for Salon"); System.out.println("----------------------"); System.out.println("# of Haircuts: " + hairCuts); System.out.println("# of Permanents: " + permanents); System.out.println("# of Colorings: " + colorings); double avg = dailyRev / customers; System.out.println("Average spent per customer: $" + avg); System.out.println("Total Revenues: $" + dailyRev); System.out.println("Total Tax: $" + dailyTax); //Check for manager bonus if (dailyRev >= 650) { bonus = dailyRev * .05; } else { bonus = 0; } dailyNet = dailyRev - bonus; System.out.println("Manager Bonus: $" + bonus); System.out.println("Total Net Revenues: $" + dailyNet); } //end of printReport public static void main(String[] args) { SalonSol salon1 = new SalonSol(); } }