Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone fix this program so it does not loop infintly & will run without issues please? Can I also get help converting it to

Can someone fix this program so it does not loop infintly & will run without issues please? Can I also get help converting it to psudocode please? it is in JAVA

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import java.text.SimpleDateFormat;

import java.util.ArrayList;

import java.util.Date;

import java.util.Scanner;

interface Service {

double price();

String description();

}

class PetGroomer {

private ArrayList services = new ArrayList<>();

public void addService(Service s) {

services.add(s);

}

public double getTotalCost() {

double total = 0;

for (Service s : services) {

total += s.price();

}

return total;

}

public void printOrder() {

System.out.println("Pet Groomer Order:");

for (Service s : services) {

System.out.println("\t" + s.description() + " - $" + s.price());

}

System.out.println("\tTotal: $" + getTotalCost());

}

public void saveOrder() throws IOException {

File file = new File("PetGroomerOrder.txt");

FileWriter writer = new FileWriter(file);

writer.write("Pet Groomer Order: ");

for (Service s : services) {

writer.write("\t" + s.description() + " - $" + s.price() + " ");

}

writer.write("\tTotal: $" + getTotalCost() + " ");

writer.close();

}

}

class BathService implements Service {

@Override

public double price() {

return 25.0;

}

@Override

public String description() {

return "Bath Service";

}

}

class HaircutService implements Service {

@Override

public double price() {

return 40.0;

}

@Override

public String description() {

return "Haircut Service";

}

}

class NailTrimService implements Service {

@Override

public double price() {

return 15.0;

}

@Override

public String description() {

return "Nail Trim Service";

}

}

public class PetGroomerOrder {

private static Scanner scanner = new Scanner(System.in);

private static PetGroomer petGroomer = new PetGroomer();

public static void main(String[] args) {

System.out.println("Pet Groomer Menu:");

System.out.println("\t1. Bath Service - $25.0");

System.out.println("\t2. Haircut Service - $40.0");

System.out.println("\t3. Nail Trim Service - $15.0");

System.out.println("\t4. Done");

while (true) {

System.out.print("Enter a menu option: ");

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

4. Explain Okuns law.

Answered: 1 week ago

Question

LOQ 13-10: What role does the internet play in group polarization?

Answered: 1 week ago