Advertisement
Majeye

Untitled

Jan 28th, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.27 KB | None | 0 0
  1. System. enter the product ID (the number to the left of the item name) that you wish to
  2. purchase.
  3. //Loop the number of times the customer entered for the number of items
  4. for(int loopCounter 0; loopCounter < itemsToPurchase; loopCounter++){
  5. //Promote the user and get item number from keyboard
  6. System.out.print("Please enter item ID number "+(loopCounter + 1)+":
  7. int itemID = keyboard.nextlnt();
  8. // Test which item the user entered
  9. //User entered 1
  10. if(itemID = 1)
  11. totalAmount = totalAmount + tennisShoeCost;
  12. //User entered 2
  13. if(item1D = 2)
  14. totalAmount = totalAmount + shirtCost;
  15. //User entered 3
  16. if(itemID = 3)
  17. totalAmount = totalAmount + coatCost;
  18. //User entered 4
  19. if(itemID = 4)
  20. totalAmount = totalAmount + beltCost;
  21. //User entered 5
  22. if(item1D = 5)
  23. totalAmount = totalAmount + pantCost;
  24. // The loop is complete, calculate the taxes and display the results
  25. double taxAmount = totalAmount * taxRate;
  26. //Show the results
  27. System. out. println("
  28. System. sales total $"+totalAmount);
  29. System. sales tax is $"+taxAmount);
  30. System. out.println("The total amount due is $"+(totalAmount + taxAmount));
  31. System. out. println("
  32. file:///C/Users/eamoore/Docments/PRG215r4 JavaProgramming/fromSMEs/PRG215 Source/srcweek 2/PRG215 Week 2.bå[7/27/2017 PM]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement