import keyboardInput.*; import java.text.DecimalFormat; public class Problem8_14 { static Keyboard in = new Keyboard(); static double priceCoff = 1.25; static double priceBag = 1.50; static double priceDan = 2.25; static double percentage = .07; static DecimalFormat x = new DecimalFormat("$#0.00"); public static void main(String args[]) { int quanCoff = howMuchCoffee(); int quanBag = howManyBagel(); int quanDan = howManyDanish(); clearScreen(); printHead(); printNew(); double allCoff = calcCoffee(quanCoff, priceCoff); printCoffee(quanCoff,allCoff); double allBag = calcBagel(quanBag, priceBag); printBagel(quanBag,allBag); double allDan = calcDanish(quanDan, priceDan); printDanish(quanDan,allDan); printNew(); double subtotal = calcSub(allCoff, allBag, allDan); printSub(subtotal); double taxable = calcTax(subtotal, percentage); printTax(taxable); printNew(); double total = calcTotal(subtotal, taxable); printTotal(total); } public static void printHead() { System.out.println("\tItem\t\tQuantity\tPrice"); return; } public static void printNew() { System.out.println("\n"); } public static int howMuchCoffee() { System.out.print("How many coffees does the customer want? "); int amount = in.readInt(); return amount; } public static double calcCoffee(int quan, double price) { double tot = quan * price; return tot; } public static void printCoffee(int quan, double totlC) { System.out.println("\tCoffee\t\t"+ quan + "\t\t" + x.format(totlC)); return; } public static int howManyBagel() { System.out.print("How many bagels does the customer want? "); int amount = in.readInt(); return amount; } public static double calcBagel(int quan, double price) { double tot = quan * price; return tot; } public static void printBagel(int quan, double totlB) { System.out.println("\tBagels\t\t"+ quan + "\t\t" + x.format(totlB)); return; } public static int howManyDanish() { System.out.print("How many danishes does the customer want? "); int amount = in.readInt(); return amount; } public static double calcDanish(int quan, double price) { double tot = quan * price; return tot; } public static void printDanish(int quan, double totlD) { System.out.println("\tDanish\t\t"+ quan + "\t\t" + x.format(totlD)); return; } public static double calcSub(double coffee, double bagel, double danish) { double subtot = coffee + bagel + danish; return subtot; } public static void printSub(double subtot) { System.out.println("\tSub Total\t \t\t" + x.format(subtot)); return; } public static double calcTax(double subtot, double percent) { double taxes = subtot * percent; return taxes; } public static void printTax(double taxable) { System.out.println("\tSales Tax\t \t\t" + x.format(taxable)); return; } public static double calcTotal(double subtot, double tax) { double tot = subtot + tax; return tot; } public static void printTotal(double tot) { System.out.println("\tTotal\t \t\t\t" + x.format(tot)); return; } public static void clearScreen() { System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); return; } }//END CLASS
welcome to mcjava's, may I take your order please?
-
you don't need to say a word
“Preach the Gospel at all times. When necessary, use words." --attributed to St. Francis of Assisi The other day, Fred Clark of slacktivist put…
-
(no subject)
It's my birthday. I was going to write something, but it doesn't want to come out. Maybe tomorrow. This entry was originally posted at…
-
very picky vampires
For those who weren't aware, my mother has leukemia. Again. She went through two bouts of leukemia in 2001 and 2004, the latter ending in a stem cell…
- Post a new comment
- 1 comment
- Post a new comment
- 1 comment