Question
Can someone help me fix this so it will run correctly please? import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; import java.text.SimpleDateFormat; import java.util.Date; public class PetGroomer
Can someone help me fix this so it will run correctly please?
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
import java.text.SimpleDateFormat;
import java.util.Date;
public class PetGroomer {
static String customerName;
static String serviceType;
static double servicePrice;
static String appointmentDate;
static String appointmentTime;
static boolean deliveryOption;
static double deliveryFee = 10.0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter your name: ");
customerName = sc.nextLine();
displayMenu();
int menuOption = sc.nextInt();
switch (menuOption) {
case 1:
serviceType = "Bath and Brush";
servicePrice = 40.0;
break;
case 2:
serviceType = "Full Grooming";
servicePrice = 60.0;
break;
case 3:
serviceType = "Nail Trimming";
servicePrice = 15.0;
break;
case 4:
serviceType = "Teeth Brushing";
servicePrice = 20.0;
break;
default:
System.out.println("Invalid option. Please try again.");
break;
}
System.out.print("Enter appointment date (MM/dd/yyyy): ");
appointmentDate = sc.next();
System.out.print("Enter appointment time (hh:mm a): ");
appointmentTime = sc.next();
System.out.print("Would you like home delivery? (yes/no): ");
String deliveryOptionInput = sc.next();
if (deliveryOptionInput.equalsIgnoreCase("yes")) {
deliveryOption = true;
servicePrice += deliveryFee;
} else {
deliveryOption = false;
}
System.out.println(" Order summary: ");
System.out.println("Customer name: " + customerName);
System.out.println("Service type: " + serviceType);
System.out.println("Service price: $" + servicePrice);
System.out.println("Appointment date: " + appointmentDate);
System.out.println("Appointment time: " + appointmentTime);
System.out.println("Home delivery: " + deliveryOption);
try {
FileWriter writer = new FileWriter("order.txt");
writer.write("Order summary: ");
writer.write("Customer name: " + customerName + " ");
writer.write("Service type: " + serviceType + " ");
writer.write("Service price: $" + servicePrice + " ");
writer.write("Appointment date: " + appointmentDate + " ");
writer.write("Appointment time: " + appointmentTime + " ");
writer.write("Home delivery: " + deliveryOption + " ");
writer.close();
} catch (IOException e) {
System.out.println("An error occurred while creating the file.");
}
}
public static void displayMenu() {
System.out
Explanation:
The Java application gives consumers the ability to order and schedule appointments for pet groomer services. The software asks the user for their name before displaying a selection of services and costs. Four options are available to the user: a bath and brush, a full grooming, cutting of the nails, and brushing of the teeth. The software will then prompt for the appointment day and time and inquire about if home delivery is desired when the user selects a service. After entering this data, the program will output the order summary and appointment information in a text file and display an order summary on the screen.
The software is composed of a variety of technical elements. Code documentation and program objectives are stated in comments. Useful data types like int, double, long, and float are employed. The variables in the code are referenced in the variable names and usage of the variables. An "Options" menu and selection are made using a switch statement. There is the employment of two or more controlled statements, such as the if, if-else, while, do-while, range-based, and for-loop ones. Order precedence, arithmetic, logical, and other parameters are all handled via operators. The program incorporates two classes, which result in the creation of objects and methods that may be used to access those objects. Control is used to access members of the class, and an array is also included. One class can utilize inheritance to include another class in its declaration. At least two interfaces are implemented in the software, and packages are imported to speed up development. Finally, design ideas are taken into account to help ensure effectiveness and efficiency.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started