Advertisement
MarufA

LabOne

Oct 2nd, 2013
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.08 KB | None | 0 0
  1. import java.util.Scanner;
  2.   class LabOne {
  3.  
  4.   public static void main(String[] args)
  5. {
  6.     Scanner scanner = new Scanner(System.in);
  7.  
  8.    
  9.     System.out.println("Hello! Please enter the name of first item:");
  10.         String item = scanner.nextLine();
  11.     System.out.println("\nPlease enter how many you want:");
  12.         int quantity = Integer.parseInt(scanner.nextLine());
  13.     System.out.println("\nPlease enter the price of the " + item);
  14.         double price = Double.parseDouble(scanner.nextLine());
  15.  
  16.  
  17.     System.out.println("\nPlease enter the name of second item:");
  18.         String item2 = scanner.nextLine();
  19.     System.out.println("\nlease enter how many you want:");
  20.         int quantity2 = Integer.parseInt(scanner.nextLine());
  21.     System.out.println("\nPlease enter the price of the " + item2);
  22.         double price2 =Double.parseDouble(scanner.nextLine());
  23.         double total2 = quantity2*price2;
  24.  
  25.    
  26.     System.out.println("\nPlease enter the name of third item:");
  27.         String item3 = scanner.nextLine();
  28.     System.out.println("\nPlease enter how many you want:");
  29.         int quantity3 = Integer.parseInt(scanner.nextLine());
  30.     System.out.println("\nPlease enter the price of the " + item3);
  31.         double price3 = Double.parseDouble(scanner.nextLine());
  32.         double total3 = quantity3*price3;
  33.  
  34.  
  35.     double total = quantity*price;
  36.  
  37.     double grandTotal = total + total2 + total3;
  38.     double salesTax = grandTotal*(.08625);
  39.     double grandTotalTaxed = grandTotal + salesTax;
  40.  
  41.  
  42.     String amount = "Quantity";
  43.     String amount1 = "Price";
  44.     String amount2 = "Total";
  45.     String taxSign = "%";
  46.  
  47.     System.out.printf("\nYour bill: ");
  48.     System.out.printf("\n\nItem");
  49.     System.out.printf("%30s", amount);
  50.  
  51.     System.out.printf("\n%30s", item);
  52.     System.out.printf("%30d", quantity);
  53.     System.out.printf("\n%30s", item2);
  54.     System.out.printf("\n%30s", item3);
  55.  
  56.  
  57.  
  58.     System.out.printf("\n\n\nSubtotal %47.2f", grandTotal);
  59.     System.out.printf("\n6.25 %s sales tax %39.2f", taxSign, salesTax);
  60.     System.out.printf("\nTotal %50.2f", grandTotalTaxed);
  61.  
  62.  
  63.  
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement