/** * CSC 211-101, Fall 2005-06 * Homework 3 - MyJava Coffee Outlet catalog business. * * The main program - Uses the MyJava class to compute the * number of small, medium, and large boxes required for * each coffee order. MyJava also has methods to compute * coffee prices. * * G. Andrus * September 19, 2005 */ import javax.swing.*; import java.util.Date; import java.text.SimpleDateFormat; import java.text.DecimalFormat; public class MainCoffee { public static void main(String[] args) { DecimalFormat df = new DecimalFormat("0.00"); Date today = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy"); JFrame jFr = new JFrame("MyJava Coffee Outlet"); jFr.setSize(400,300); jFr.setVisible(true); // Accept coffee order from customer String noBagsStr = JOptionPane.showInputDialog(jFr, "How many bags of coffee would\n you like to order:"); int noBags = Integer.parseInt(noBagsStr); // All computations are done by a coffee object MyJava coffee = new MyJava(noBags); // Compute price for coffee ordered System.out.println("Number of Bags Ordered: " + noBags + " - $ " + df.format(coffee.price())); System.out.println("Date of Order:\t" + sdf.format(today)); System.out.println("\nBoxes Used:"); // Compute the number of each size box required for the order. // Also, compute box price and total cost of the order. System.out.println("\t\t" + coffee.numLgBoxes() + " Large - $" + df.format(coffee.numLgBoxes() * 1.8)); System.out.println("\t\t" + coffee.numMedBoxes() + " Medium - $" + df.format(coffee.numMedBoxes() * 1.0)); System.out.println("\t\t" + coffee.numSmBoxes() + " Small - $" + df.format(coffee.numSmBoxes() * 0.6)); System.out.println("\nYour total cost is: $ " + df.format(coffee.totalPrice())); System.exit(0); } }