I need to modify this code for my Java class and I'm doing something wrong because it's not compiling correctly.
I need to modify the code so that when the user ends the program it displays the number of invoices, the average invoice amount, and the average discount amount.
I'm not sure if I'm just not initializing the variables correctly, or if I'm doing it in the wrong place ...
Here is the code:
public class InvoiceApp
public static void main(String args)
System.out.println("Welcome to the Invoice Total Calculator");
System.out.println(); // print a blank line
Scanner sc = new Scanner(System.in); // do I need to initialize variables here? Or would I just work with the variables below?
String choice = "y";
System.out.print("Enter subtotal: ");
double subtotal = sc.nextDouble();
double discountPercent = 0.0;
if (subtotal >= 200)
discountPercent = .2;
else if (subtotal >= 100)
discountPercent = .1;
discountPercent = 0.0;
double discountAmount = subtotal * discountPercent;
double total = subtotal - discountAmount;
String message = "Discount percent: " + discountPercent + "\n"
+ "Discount amount: " + discountAmount + "\n"
+ "Invoice total: " + total + "\n";
System.out.print("Continue? (y/n): ");
choice = sc.next(); //I'm assuming that the commands to print the number of invoices, etc., would go here?