// Introduction to Java programming //***************************************************** // Once you've got Java on your system, the //quickest and best way to learn Java programming is //to do Java programming. That's why this chapter //shows you how to write complete Java programs that //get input from a user, make calculations, and //display output. When you finish this chapter, //you should be able to write comparable programs of //your own. //***************************************************** import java.util.Scanner; public class InvoiceApp { public static void main(String[] args) { //display a welcome message System.out.println("Welcome to the Invoice Total Calculator"); System.out.print(); // print a blank line // get the input from the user Scanner sc = new Scanner(System.in); System.out.print("Enter subtotal: "); double subtotal = sc.nextDouble(); // calculate the discount amount and total double discountPercent = .2; double discountAmount = subtotal * discountPercent; double invoiceTotal = subtotal - discountAmount; // format and display the result String message = "Discount percent: " + discountPercent + "\n" + "Discount amount: " + discountAmount + "\n" + "Invoice total: " + invoiceTotal + "\n"; System.out.println(message); } }