Question: JAVA! I am creating a small and simple program that books appointments for Dogs and Cat for a Grooming business. Using Notepad for the code

JAVA!

I am creating a small and simple program that books appointments for Dogs and Cat for a Grooming business.

Using Notepad for the code and the command prompt to execute.

Can someone help me with issue i'm running into with my code.

When it prompts user to select dog or cats the program will ask if the user wants full grooming or self service wash.

my code creates 2 different ticket numbers.

I need help finishing the when customer selects full grooming or self service wash.

ALSO HELP: with adding JDatePicker Swing library: The program should prompt the user to select products or services and appointment or delivery date and time from the available options in the 1 year span.

CODE:

import java.util.Scanner; import java.util.Date;

public class groomingreserv {

// Create an array of 12 appts, 6 for dogs and 6 cats from 9AM-5PM. private static int[] appts= new int[12];

public static void main(String args[]) { System.out.println("Welcome to Shiney Paws & Claws!"); System.out.println("Now providing full and self-service pet grooming in the Inland Empire!"); System.out.println("Address: 16379 Foothill Blvd., Fontana, CA 92335"); System.out.println("Hours of operation: Monday - Friday from 9AM-5PM"); System.out.println("Grooming service pick up must be done before 5PM. Late pick up will include extra charge."); System.out.println("Self-Service appoitment available until 4:30PM."); System.out.println("Mask are required at all time. Thank you for your understanding."); System.out.println();

// Lets start by setting all appts equal to 0 (aka Empty) for (int i = 0; i < 12; i++) { appts[i] = 0; }

// Setup our scanner and default the choice to window. Scanner s = new Scanner(System.in); int choice = 1;

// Ask user to input appointment either for Dog or Cat. System.out.print("Please enter 1 to book an appointment for your 'Dog', or enter 2 to book an appointment for your 'Cat.' Enter 0 to exit: "); choice = s.nextInt();

// Execute booking if user selects 0. while (choice != 0) { int apptnumber = 0;

// If they chose appt for "Dog", attempt to book it. if (choice == 1) { apptnumber = bookDog();

// No full grooming appt available, try booking a self-service appt. if (apptnumber == -1) { apptnumber = bookCat();

if (apptnumber != -1) { System.out.println("Sorry, we were not able to book full grooming appt. But do have self-service appt available."); printApptPass(apptnumber); } }

else { // Booking appt was successful. System.out.println("You are in luck, we have an appoitment available for you!"); printApptPass(apptnumber); } }

else if (choice == 2) { // If they chose booking for cat, check to see if it is available. apptnumber = bookCat();

// If not available, see if we have dog appt available. if (apptnumber == -1) { apptnumber = bookDog(); if (apptnumber != -1) { System.out.println("Sorry, we were not able to book. But do have self service appt."); printApptPass(apptnumber); } }

else {

// Booking an appt was successful. System.out.println("You are in luck, we have an appoitment available for you!"); printApptPass(apptnumber); } }

else { // Print an error message if they did not choose 1, 2, or 0 for their choice. System.out.println("Invalid choice made. Please try again!"); choice = 0; }

// No dogs or aisle seats were available. if (apptnumber == -1) { System.out.println("We are sorry, there are no window or aisle seats available."); System.out.println(); }

// Reprompt for a choice System.out.print("Please enter 1 for Complete Service Grooming, 2 for Self-Service Grooming or 0 to exit: "); choice = s.nextInt(); } } // This function checks for dogs appts and returns cat appts or -1 if full. private static int bookDog() { for (int i = 0; i < 6; i++) { if (appts[i] == 0) { appts[i] = 1; return i + 1; } } return -1; }

// This function checks to see if appts were available, -1 if full. private static int bookCat() { for (int i = 6; i < 12; i++) { if (appts[i] == 0) { appts[i] = 1; return i + 1; } } return -1; } // This simply prints out a nice little pass message with their appt number and date of issue. private static void printApptPass(int apptnumber) { Date timenow = new Date(); System.out.println(); System.out.println("Date: " + timenow.toString()); System.out.println("Appoitment reservation #: " + apptnumber); System.out.println("This appoitment is non-refundable and non-transferable. To reschedule please call us at 909-320-8669. Thank you!"); System.out.println("Please be curteous and arrive on time!"); System.out.println(); }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!