Results 1 to 2 of 2
  1. #1
    jonboy26 is offline Member
    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    Default invoiceApp help with coding

    I am simply trying to calculate the number of invoices: the average invoice: and the average discount:, the code i have been working with is at the bottom. I appreciate any help with this.




    import java.text.DecimalFormat;
    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";
    while (choice.equalsIgnoreCase("y")) {
    while (!choice.equalsIgnoreCase("n"))
    {
    // get the invoice subtotal from the user
    System.out.print ("Enter subtotal: ");
    double subtotal = sc.nextDouble();

    // calculate the discount amount and total
    double discountPercent= 0.0;
    if (subtotal >= 200) {
    discountPercent = .25;
    }
    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();


    // display the score count, score total, and average score
    double numberInvoices = total += 1;
    double averageInvoice = total /= invoiceCount;
    double averageDiscount = discountAmount /= numberofInvoices;

    System.out.println( + "Number of invoices: " + numberofInvoices + "\n");
    System.out.println( + "Average invoice: " + averageInvoice + "\n");
    System.out.println( + "Average discount: " + averageDiscount + "\n");
    System.out.println(message);
    }
    }}

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default Re: invoiceApp help with coding

    Please edit the post and wrap the code in code tags. See: BB Code List - Java Programming Forum

    Can you post the program's output and explain what is wrong with it and show what it should be.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Need Help Coding IO
    By loopsnhoops in forum New To Java
    Replies: 1
    Last Post: 05-18-2011, 03:44 PM
  2. Replies: 4
    Last Post: 10-25-2010, 03:49 PM
  3. Need help coding
    By ace_03 in forum New To Java
    Replies: 2
    Last Post: 11-25-2009, 05:16 PM
  4. Coding help
    By Java_Fanatic in forum New To Java
    Replies: 7
    Last Post: 10-15-2009, 04:37 AM
  5. coding help
    By accies76 in forum New To Java
    Replies: 5
    Last Post: 11-12-2008, 08:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •