The LineItemApp class

import java.util.Scanner; public class LineItemApp { public static void main(String args[]) { // display a welcome message System.out.println("Welcome to the Line Calculator"); System.out.println(); // create 1 or more line item Scanner sc = new Scanner(System.in); String choice = "y"; while (choice.equalsIgnoreCase("y")) { // get the inpute from the user String productCode = Validator.getString(sc, "Enter product code: "); int quantity = Validator.getInt(sc, "Enter quantity: ", 0, 1000); // get the Product object Product product = ProductDB.getProduct(productCode); // create the LineItem object LineItem lineitem = new LineItem(product, quantity); // display the output System.out.println(); System.out.println("Line ITEM"); System.out.println("Code: " + product.getCode()); System.out.println("Description: " + product.getDescription()); System.out.println("Price: " + product.getFormattedPrice()); System.out.println("Quantity: " + product.getQuantity()); System.out.println("Total: " + product.getFormattedTotal() + "\n"); // see if the user wants to continue choice = Validator.getString(sc, "Continue? (y/n): "); System.out.println(); } } } ******************************************************* page 215 | | | | | | | | | | | | | | | | |
Site hosted by Angelfire.com: Build your free website today!