galinyotsev123

ProgBasicsExam3and4November2018-E03weddingInvestment

Dec 30th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class E03weddingInvestment {
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. String timeOfContract = scanner.nextLine();
  9. String typeOfContract = scanner.nextLine();
  10. String ifdesert = scanner.nextLine();
  11. double months = Double.parseDouble(scanner.nextLine());
  12.  
  13. double price = 0;
  14. double priceDesert = 0;
  15. double finalPriceDesert = 0;
  16. double total = 0;
  17.  
  18. switch (typeOfContract)
  19. {
  20. case "Small":
  21. switch (timeOfContract)
  22. {
  23. case "one":
  24. price = 9.98;
  25. break;
  26. case "two":
  27. price = 8.58;
  28. break;
  29. default:
  30. break;
  31. }
  32.  
  33. break;
  34. case "Middle":
  35. switch (timeOfContract)
  36. {
  37. case "one":
  38. price =18.99;
  39. break;
  40. case "two":
  41. price = 17.09;
  42. break;
  43. default:
  44. break;
  45. }
  46. break;
  47. case "Large":
  48. switch (timeOfContract)
  49. {
  50. case "one":
  51. price = 25.98 ;
  52. break;
  53. case "two":
  54. price = 23.59;
  55. break;
  56. default:
  57. break;
  58. }
  59. break;
  60. case "ExtraLarge":
  61. switch (timeOfContract)
  62. {
  63. case "one":
  64. price = 35.99;
  65. break;
  66. case "two":
  67. price = 31.79;
  68. break;
  69. default:
  70. break;
  71. }
  72.  
  73. break;
  74. default:
  75. break;
  76. }
  77.  
  78.  
  79.  
  80. if (ifdesert.equalsIgnoreCase("yes"))
  81. {
  82. if (price <= 10)
  83. {
  84. priceDesert = 5.50;
  85. }
  86. else if (price <= 30)
  87. {
  88. priceDesert = 4.35;
  89. }
  90. else if (price > 30)
  91. {
  92. priceDesert = 3.85;
  93. }
  94. }
  95.  
  96. if (timeOfContract.equalsIgnoreCase( "two"))
  97. {
  98. double totalPrice = price + priceDesert;
  99. double discount = totalPrice * 0.0375;
  100. total = (totalPrice - discount)* months;
  101.  
  102. }
  103. else
  104. {
  105. total = (price + priceDesert)* months;
  106. }
  107.  
  108.  
  109. System.out.printf("%.2f lv.", total);
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment