Skip to content

Invoice App

Invoice Application

  1. Create a new class called InvoiceApplication

    • ▾ 📂 src
    • ▾ 📦 (default package)
      • 📄 InvoiceApplication.java

  2. Add the code below

InvoiceApplication
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import java.util.Scanner;

public class InvoiceApplication
{
    public static void main(String[] args)
    {
        double subtotal = 100;
        double discountPercent = 0.2;
        double discountAmount = subtotal * discountPercent;
        double total = subtotal - discountAmount;
        // welcome the user to the program
        System.out.println("Welcome to the Invoice Total Calculator");
        System.out.println(); // print a blank line
        // display the discount amount and total
        System.out.println("Subtotal:           " + subtotal);
        System.out.println("Discount percent:   " + discountPercent);
        System.out.println("Discount amount:    " + discountAmount);
        System.out.println("Total:              " + total);
    }
}
  1. Run the program and you should see the following output.
Console Output
Welcome to the Invoice Total Calculator  

Subtotal:           100.0  
Discount percent:   0.2  
Discount amount:    20.0  
Total:              80.0

InvoiceApplication.java