[java] kk
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- Scanner input = new Scanner(System.in);
- double coffeeTot = 10;
- double donutTot = 10;
- double coffeePrice = 7.5;
- double donutPrice = 4.25;
- double subtotal=0;
- double discountedPrice = 0;
- double total;
- System.out.println("Welcome to JAVA CAFE");
- System.out.println("Please, enter order(#cups of coffee , and #dounuts)");
- double coffeeCot = input.nextInt();
- double donutCot = input.nextInt();
- if(coffeeCot<=coffeeTot && donutCot<=donutTot){
- System.out.println("Are you student (true for yes, false for no )?");
- boolean isStudent= input.nextBoolean();
- subtotal = (coffeeCot*coffeePrice)+ (donutCot*donutPrice);
- if(isStudent==true){
- discountedPrice = subtotal*0.10;
- total = subtotal-discountedPrice;
- }else {
- discountedPrice =0;
- total=subtotal;
- }
- System.out.println("---------------------------------------------------------");
- System.out.printf("Item\t\t\tQuantity\t\tPrice\n");
- System.out.printf("Coffe\t\t\t %.2f\t\t\t%.2f\n",coffeeCot , (coffeeCot * coffeePrice));
- System.out.printf("Donuts\t\t\t %.2f\t\t\t%.2f\n" , donutCot , (donutCot * donutPrice));
- System.out.println("-----------------------------------------------------------");
- System.out.printf("Sub Total\t\t\t\t\t%.2f\n" , subtotal);
- System.out.printf("Discount\t\t\t\t\t %.2f%n" , discountedPrice);
- System.out.println("-----------------------------------------------------------");
- System.out.printf("Total\t\t\t\t\t\t%.2f\n" , total);
- } else {
- System.out.println("Error:not enough cups and/or donuts");
- }
Editor
You can edit this paste and save as new: