Question: The folloing to java files input 5 objects into an array and can then be sorted by invoice number or price. Make the following two
The folloing to java files input 5 objects into an array and can then be sorted by invoice number or price. Make the following two modifications:
1. Enhance the program by displaying a menu that asks the user how they want to sort the services menu. 1) Sort by Service Description, 2) Sort by Price, 3) Sort by Time (Minutes), or 0) to Exit.
2. Add a do...while() loop that keeps prompting the user for the next preferred sort order until the user finally chooses 0 to exit
import java.util.Scanner; public class SortPurchasesArray { public static void main(String[] args) { final int size = 5; int i; Purchase[] purchase = new Purchase[size]; Scanner input = new Scanner(System.in); for(i = 0; i public class Purchase { private final double tax = .05; private int invoiceNumber; private double saleAmount; private double salesTax; public void setInvoice(int invoiceNumber) { this.invoiceNumber=invoiceNumber; } public void setAmount(double saleAmount) { this.saleAmount=saleAmount; salesTax = saleAmount*tax; } public int getInvoice() { return invoiceNumber; } public double getAmount() { return saleAmount; } public double getTax() { return salesTax; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
