/*Practical Task: BOBS*/ import java.util.*; public class TaskMN { public static void main (String [] args) { Scanner in = new Scanner (System.in); String name = ""; int bolts = 0; int nuts = 0; int washers = 0; int rand = 0; String invoiceCode = ""; int counter = 0; double total = 0.0; double vat = 0.0; double netTotal = 0.0; String business = "Bobs Discount Bolts"; String capitals = business.toUpperCase(); int length = business.length (); String counterString = Integer.toString(counter); System.out.print("Please enter your name\t\t\t: "); name = in.nextLine(); do { System.out.print("\nHow many bolts would you like to purchase : "); bolts = in.nextInt(); System.out.print("\nHow many nuts would you like to purchase : "); nuts = in.nextInt(); System.out.print("\nHow many washers would you like to purchase : "); washers = in.nextInt(); for (int x = 1;x<= 3; x++) { rand = (int)(Math.random()* length); invoiceCode = invoiceCode + (capitals.substring(rand,rand+1)); counter = counter + 1; } double bPrice = Prices.getBoltPr(); double nPrice = Prices.getNutPr(); double wPrice = Prices.getWasherPr(); total = (bolts * bPrice) + (nuts * nPrice) + (washers * wPrice); vat = (double)total*14/100; netTotal = vat + total; System.out.println("Your code is: "+invoiceCode+counter); invoiceCode = ""; System.out.println("\n\t\t\t\t\tBob's Discount Store"); System.out.println("59 Mahatma Gandhi Street\t\t\t\t\t\tTelephone: 552 1234"); System.out.println("STANGER\t\t\t\t\t\t\t\tFax: 552 5678"); System.out.println("4450\t\t\t\t\t\t\t\tEmail: bobs@webmail.co.za"); System.out.println(" "); System.out.println("------------------------------------------------------------------------------------------------------"); System.out.println(" "); System.out.println("Number \t \t \t Description \t \t \t Unit Price \t \t \tTotal"); System.out.printf(bolts + " \t\t \t \t Bolts \t \t \t \t 25c \t \t \t \tR%4.2f\n",bolts * bPrice); System.out.printf(nuts + " \t\t \t \t Nuts \t \t \t \t 15c \t \t \t \tR%4.2f\n",nuts * nPrice); System.out.printf(washers + "\t \t \t \t Washers \t \t \t 10c \t \t \t \tR%6.2f\n",washers * wPrice); System.out.println(" "); System.out.println("-----------------------------------------------------------------------------------------------------"); System.out.println(" "); System.out.printf("Total \t \t \t \t \t \t \t \t \t \t \t R%6.2f\n", total); System.out.println("Vat (14%) \t \t \t \t \t \t \t \t \t \t " + vat); System.out.println(" "); System.out.println("-----------------------------------------------------------------------------------------------------"); System.out.println(" "); System.out.println("Customer Owes \t \t \t \t \t \t \t \t \t \t R"+ netTotal); System.out.println(" "); if (bolts>nuts) { System.out.println("\n**Check out the order!**"); }else { System.out.println("\n**Order is correct!**"); System.out.print("\nPlease enter your name:\t\t\t"); name = in.next(); } }while (!(name.equalsIgnoreCase("ZZZ"))); } }