the one and only truly amazing katster (katster) wrote,
the one and only truly amazing katster
katster

  • Mood:

welcome to mcjava's, may I take your order please?



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
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 1 comment