Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. }
  2. public static void main(String[] args)
  3. {
  4. Scanner input = new Scanner (System.in);
  5. int options = 0;
  6. int hardware2 = 2;
  7. int amountbook = 0;
  8. // Apart of purchasing texbooks
  9. double javabook = 59.99;
  10. double cplusbook = 49.99;
  11. int javaorcplus = 0;
  12. // buying hardware
  13. double laptop = 1000.00;
  14. double monitor = 250.00;
  15.  
  16. int LTorMT = 0;
  17. // LT is laptop, MT is monitor
  18.  
  19. System.out.println("1) Purchase textbooks");
  20. System.out.println("2) Purchase hardware");
  21. System.out.println("3) Show total and exit");
  22.  
  23. options = input.nextInt();
  24.  
  25. switch (options)
  26. {
  27. case 1:
  28. System.out.println("1) Purchase Java: How to Program ($59.99)");
  29. System.out.println("2) Purchase C++: How to Program ($49.99)");
  30.  
  31. javaorcplus = input.nextInt();
  32.  
  33. if (javaorcplus == 1)
  34. {
  35. System.out.println("How many? (1-5)");
  36. amountbook = input.nextInt();
  37. System.out.println("You have chosen " +
  38. amountbook);
  39. System.out.println("Your subtotal is " +
  40. amountbook * javabook);
  41. }
  42.  
  43. else if (javaorcplus == 2)
  44. {
  45. System.out.println("How many? (1-5)");
  46. amountbook = input.nextInt();
  47. System.out.println("You have chosen " +
  48. amountbook);
  49. System.out.println("Your subtotal is"
  50. +amountbook * cplusbook);
  51. }
  52.  
  53. break;
  54. case 2:
  55. System.out.println("1) Purchase Laptop ($1,000.00)");
  56. System.out.println("2) Purchase Monitor ($250.00)");
  57.  
  58. LTorMT = input.nextInt();
  59.  
  60. if (LTorMT == 1)
  61. {
  62. System.out.println(laptop);
  63. }
  64. else
  65. {
  66. System.out.println(monitor);
  67. }
  68.  
  69.  
  70. break;
  71. case 3:
  72. double total = totalpurchase(amountbook);
  73. System.out.println("Your total is " + total);
  74. break;
  75.  
  76. default:
  77. System.out.println("Please pick an option");
  78. break;
  79.  
  80. }
  81.  
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement