Need help figuring out where i went wrong with last


Need help figuring out where I went wrong with last question in my entry to Java programming class.

Modify the code so it displays the number of invoices, the average invoice amount, and the average discount amount when the user ends the program. Then, test this change.

I have been able to complete through number 3 and my Java code is below. I am having issues with developing the code for number 4, but did insert the count statement for the invoices. I have italicized all my changes. Any help is appreciated.
import java.util.Scanner;
public class InvoiceApp
{
public static void main(String[] args)
{
// welcome the user to the program
System.out.println("Welcome to the Invoice Total Calculator");
System.out.println(); // print a blank line
// create a Scanner object named sc
Scanner sc = new Scanner(System.in);
// perform invoice calculations until choice isn't equal to "y" or "Y"
String choice = "y";
int invoices = 0;
double invoiceAmount = 0;
double invoiceDiscount = 0;
while (!choice.equalsIgnoreCase("n"))
{
// get the invoice subtotal from the user
System.out.print("Enter subtotal: ");
double subtotal = sc.nextDouble();
//count number of invoices
invoices = invoices + 1;
// calculate the discount amount and total
double discountPercent= 0.0;
if (subtotal >= 500)
discountPercent = .25;
else if (subtotal >= 200)
discountPercent = .2;
else if (subtotal >= 100)
discountPercent = .1;
else
discountPercent = 0.0;
double discountAmount = subtotal * discountPercent;
double total = subtotal - discountAmount;
// display the discount amount and total
String message = "Discount percent: " + discountPercent + "n"
+ "Discount amount: " + discountAmount + "n"
+ "Invoice total: " + total + "n";
System.out.println(message);
// see if the user wants to continue
System.out.print("Continue? (y/n): ");
choice = sc.next();
System.out.println();
}
}
}

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Need help figuring out where i went wrong with last
Reference No:- TGS02387541

Now Priced at $10 (50% Discount)

Recommended (99%)

Rated (4.3/5)