rendered paste body 1. /*Practical Task: BOBS*/ 2. import java.util.*; 3. public class TaskMN 4. { 5. 6. public static void main (String [] args) 7. { 8. Scanner in = new Scanner (System.in); 9. String name = ""; 10. int bolts = 0; 11. int nuts = 0; 12. int washers = 0; 13. int rand = 0; 14. String invoiceCode = ""; 15. int counter = 0; 16. double total = 0.0; 17. double vat = 0.0; 18. double netTotal = 0.0; 19. String business = "Bobs Discount Bolts"; 20. String capitals = business.toUpperCase(); 21. int length = business.length (); 22. String counterString = Integer.toString(counter); 23. System.out.print("Please enter your name\t\t\t: "); 24. name = in.nextLine(); 25. do 26. { 27. System.out.print("\nHow many bolts would you like to purchase : "); 28. bolts = in.nextInt(); 29. System.out.print("\nHow many nuts would you like to purchase : "); 30. nuts = in.nextInt(); 31. System.out.print("\nHow many washers would you like to purchase : "); 32. washers = in.nextInt(); 33. for (int x = 1;x<= 3; x++) 34. { 35. rand = (int)(Math.random()* length); 36. invoiceCode = invoiceCode + (capitals.substring(rand,rand+1)); 37. counter = counter + 1; 38. } 39. 40. double bPrice = Prices.getBoltPr(); 41. double nPrice = Prices.getNutPr(); 42. double wPrice = Prices.getWasherPr(); 43. total = (bolts * bPrice) + (nuts * nPrice) + (washers * wPrice); 44. vat = (double)total*14/100; 45. netTotal = vat + total; 46. System.out.println("Your code is: "+invoiceCode+counter); 47. invoiceCode = ""; 48. System.out.println("\n\t\t\t\t\tBob's Discount Store"); 49. System.out.println("59 Mahatma Gandhi Street\t\t\t\t\t\tTelephone: 552 1234"); 50. System.out.println("STANGER\t\t\t\t\t\t\t\tFax: 552 5678"); 51. System.out.println("4450\t\t\t\t\t\t\t\tEmail: bobs@webmail.co.za"); 52. System.out.println(" "); 53. System.out.println("------------------------------------------------------------------------------------------------------"); 54. System.out.println(" "); 55. System.out.println("Number \t \t \t Description \t \t \t Unit Price \t \t \tTotal"); 56. System.out.printf(bolts + " \t\t \t \t Bolts \t \t \t \t 25c \t \t \t \tR%4.2f\n",bolts * bPrice); 57. System.out.printf(nuts + " \t\t \t \t Nuts \t \t \t \t 15c \t \t \t \tR%4.2f\n",nuts * nPrice); 58. System.out.printf(washers + "\t \t \t \t Washers \t \t \t 10c \t \t \t \tR%6.2f\n",washers * wPrice); 59. System.out.println(" "); 60. System.out.println("-----------------------------------------------------------------------------------------------------"); 61. System.out.println(" "); 62. System.out.printf("Total \t \t \t \t \t \t \t \t \t \t \t R%6.2f\n", total); 63. System.out.println("Vat (14%) \t \t \t \t \t \t \t \t \t \t " + vat); 64. System.out.println(" "); 65. System.out.println("-----------------------------------------------------------------------------------------------------"); 66. System.out.println(" "); 67. System.out.println("Customer Owes \t \t \t \t \t \t \t \t \t \t R"+ netTotal); 68. System.out.println(" "); 69. if (bolts>nuts) 70. { 71. System.out.println("\n**Check out the order!**"); 72. }else 73. { 74. System.out.println("\n**Order is correct!**"); 75. 76. System.out.print("\nPlease enter your name:\t\t\t"); 77. name = in.next(); 78. 79. } 80. }while (!(name.equalsIgnoreCase("ZZZ"))); 81. } 82. } Raw Content Download: http://www.pastebin.ca/raw/390815