Answered step by step
Verified Expert Solution
Question
1 Approved Answer
can someone please help me solve this error here is my code import import java.util.Scanner; public class ReceiptMaker { public static final String SENTINEL =
can someone please help me solve this error here is my code import import java.util.Scanner;
public class ReceiptMaker
public static final String SENTINEL "checkout";
public final int MAXNUMITEMS;
public final int TAXRATE;
private String itemNames;
private double itemPrices;
private int numItemsPurchased;
public ReceiptMaker
MAXNUMITEMS ;
TAXRATE ;
itemNames new StringMAXNUMITEMS;
itemPrices new doubleMINNUMITEMS;
numItemsPurchased ;
public ReceiptMakerint maxNumItems, double taxRate
ifisValidmaxNumItems
MAXNUMITEMS maxNumItems;
else
MAXNUMITEMS;
ifisValidtaxRate
TAXRATE taxRate;
else
TAXRATE ;
itemNames new StringMAXNUMITEMS;
itemPrices new doubleMAXNUMITEMS;
numItemsPurchased ;
public void greetUser
System.out.printlnWelcome to the MAXNUMITEMS items or less checkout line";
public void promptUserForProductEntry
System.out.printlnEnter item #numItemsPurchaseds name and price separated by a space, or enter SENTINEL to end transaction early";
public void addNextPurchaseItemFromUserString itemName, double itemPrice
itemNamesnumItemsPurchased itemName;
itemPricesnumItemsPurchased itemPrice;
numItemsPurchased;
public double getSubtotal
double subTotal ;
forint i; i maxPrice
maxPrice itemPricesi;
return maxPrice;
public int getIndexOfMaxPrice
int indexOfMax ;
forint i; i itemPricesindexOfMax
indexOfMax numItemsPurchased;
return indexOfMax;
public double getMeanPrice
return getSubtotalnumItemsPurchased;
public double getTaxOnSubtotal
return getSubtotal TAXRATE;
public double getTotal
return getSubtotal getTaxOnSubtotal;
public void displayReceipt
System.out.println;
System.out.printfSubtotal: $ f # of Items d
getSubtotalnumItemsPurchased;
System.out.printf Tax: $ f
getTaxOnSubtotal;
System.out.printf Total: $ f
getTotal;
System.out.printlnTHANK YOU;
public void displayReceiptStats
System.out.println
RECEIPT STATS;
System.out.printfMin Item Name: s Price: $ f
itemNamesgetIndexOfMinPrice getMinPrice;
System.out.printMax Item Name: s Price: $ f
itemNamesgetIndexOfMaxPrice getMaxPrice;
System.out.printfMean price of d items purchased: $ f
numItemsPurchased, getMeanPrice;
public void displayAllItemsWithPrices
System.out.println
RECEIPT BREAKDOWN;
forint i; i;
private boolean isValiddouble a
return a ;
public static void mainString args
Scanner scanner new ScannerSystemin;
ReceiptMaker rm new ReceiptMaker;
rmgreetUser;
rmscanCartItemsscanner;
rmdisplayReceipt;
rmdisplayReceiptStats;
rmdisplayAllItemsWithPrices;
scanner.close;
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