Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class LabOne {
- public static void main(String[] args)
- {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Hello! Please enter the name of first item:");
- String item = scanner.nextLine();
- System.out.println("\nPlease enter how many you want:");
- int quantity = Integer.parseInt(scanner.nextLine());
- System.out.println("\nPlease enter the price of the " + item);
- double price = Double.parseDouble(scanner.nextLine());
- System.out.println("\nPlease enter the name of second item:");
- String item2 = scanner.nextLine();
- System.out.println("\nlease enter how many you want:");
- int quantity2 = Integer.parseInt(scanner.nextLine());
- System.out.println("\nPlease enter the price of the " + item2);
- double price2 =Double.parseDouble(scanner.nextLine());
- double total2 = quantity2*price2;
- System.out.println("\nPlease enter the name of third item:");
- String item3 = scanner.nextLine();
- System.out.println("\nPlease enter how many you want:");
- int quantity3 = Integer.parseInt(scanner.nextLine());
- System.out.println("\nPlease enter the price of the " + item3);
- double price3 = Double.parseDouble(scanner.nextLine());
- double total3 = quantity3*price3;
- double total = quantity*price;
- double grandTotal = total + total2 + total3;
- double salesTax = grandTotal*(.08625);
- double grandTotalTaxed = grandTotal + salesTax;
- String amount = "Quantity";
- String amount1 = "Price";
- String amount2 = "Total";
- String taxSign = "%";
- System.out.printf("\nYour bill: ");
- System.out.printf("\n\nItem");
- System.out.printf("%30s", amount);
- System.out.printf("\n%30s", item);
- System.out.printf("%30d", quantity);
- System.out.printf("\n%30s", item2);
- System.out.printf("\n%30s", item3);
- System.out.printf("\n\n\nSubtotal %47.2f", grandTotal);
- System.out.printf("\n6.25 %s sales tax %39.2f", taxSign, salesTax);
- System.out.printf("\nTotal %50.2f", grandTotalTaxed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement