Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Here is a java file that I need your help to check if it can function properly. If there is a problem, please let me
Here is a java file that I need your help to check if it can function properly. If there is a problem, please let me know how to change it if there is no problem, please let me know, thank you. import java.util.Scanner; class DimSum private String name; private float price; private int quantity; public DimSumString name, float price this.name name; this.price price; this.quantity ; public String getName return name; public float getPrice return price; public int getQuantity return quantity; public void orderint quantity this.quantity quantity; public class DimSumOrdering This stores the dim sum dishes in the system DimSum dishes; The constructor of DimSumOrdering public DimSumOrdering Initialize the dim sum dishes in the system dishes new DimSum; dishes new DimSumSiu Mai", f; dishes new DimSumBarbecued Pork Bun", f; dishes new DimSumShrimp Dumpling", f; dishes new DimSumSpring Roll", f; Start the ordering system public void start Scanner scanner new ScannerSystemin; String choice; do Print the menu System.out.printlnMenu:; for int i ; i dishes.length; i System.out.printlni dishesigetName $ dishesigetPrice; System.out.println Bill and payment"; Read the input choice scanner.next; Process the choice switch choice case : dishesorder; System.out.printlnOrdered dishesgetName; break; case : dishesorder; System.out.printlnOrdered dishesgetName; break; case : dishesorder; System.out.printlnOrdered dishesgetName; break; case : dishesorder; System.out.printlnOrdered dishesgetName; break; case : Show the bill and order summary System.out.printlnOrder Summary:"; float total ; for int i ; i dishes.length; i int quantity dishesigetQuantity; if quantity float subtotal quantity dishesigetPrice; System.out.printlndishesigetName: quantity x $ dishesigetPrice $ subtotal; total subtotal; System.out.printlnTotal: $ total; break; default: System.out.printlnInvalid choice. Please select again."; break; while choice.equals; scanner.close; public static void mainString args DimSumOrdering orderingSystem new DimSumOrdering; orderingSystem.start;
Here is a java file that I need your help to check if it can function properly.
If there is a problem, please let me know how to change it
if there is no problem, please let me know, thank you.
import java.util.Scanner;
class DimSum
private String name;
private float price;
private int quantity;
public DimSumString name, float price
this.name name;
this.price price;
this.quantity ;
public String getName
return name;
public float getPrice
return price;
public int getQuantity
return quantity;
public void orderint quantity
this.quantity quantity;
public class DimSumOrdering
This stores the dim sum dishes in the system
DimSum dishes;
The constructor of DimSumOrdering
public DimSumOrdering
Initialize the dim sum dishes in the system
dishes new DimSum;
dishes new DimSumSiu Mai", f;
dishes new DimSumBarbecued Pork Bun", f;
dishes new DimSumShrimp Dumpling", f;
dishes new DimSumSpring Roll", f;
Start the ordering system
public void start
Scanner scanner new ScannerSystemin;
String choice;
do
Print the menu
System.out.printlnMenu:;
for int i ; i dishes.length; i
System.out.printlni dishesigetName $ dishesigetPrice;
System.out.println Bill and payment";
Read the input
choice scanner.next;
Process the choice
switch choice
case :
dishesorder;
System.out.printlnOrdered dishesgetName;
break;
case :
dishesorder;
System.out.printlnOrdered dishesgetName;
break;
case :
dishesorder;
System.out.printlnOrdered dishesgetName;
break;
case :
dishesorder;
System.out.printlnOrdered dishesgetName;
break;
case :
Show the bill and order summary
System.out.printlnOrder Summary:";
float total ;
for int i ; i dishes.length; i
int quantity dishesigetQuantity;
if quantity
float subtotal quantity dishesigetPrice;
System.out.printlndishesigetName: quantity x $ dishesigetPrice $ subtotal;
total subtotal;
System.out.printlnTotal: $ total;
break;
default:
System.out.printlnInvalid choice. Please select again.";
break;
while choice.equals;
scanner.close;
public static void mainString args
DimSumOrdering orderingSystem new DimSumOrdering;
orderingSystem.start;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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