Question: 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;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
