Advertisement
MladenKarachanov

Untitled

Dec 20th, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.51 KB | None | 0 0
  1. Основи на програмирането"
  2. Задача 3. Компютърна зала
  3. В най-голямата компютърна зала в България цените варират поради голямата посещаемост. Таксите на залата са в зависимост от това дали е ден или нощ, както и месецът, в който се посещава залата. Цените са следните:
  4. Март до Май Юни до Август
  5. Ден 10.50 лв/ч 12.60 лв/ч
  6. Нощ 8.40 лв/ч 10.20 лв/ч
  7. Предлагат се и следните отстъпки в следната последователност:
  8. • За група от четирима или повече човека, цената на човек се намаля с 10%
  9. • За 5 или повече часа прекарани, цената на човек се намаля с 50%
  10. Да се напише програма, която изчислява цената на човек за час и общата сума.
  11. Вход:
  12. Входът се чете от конзолата и съдържа точно 4 реда:
  13. • На първия ред - месецът - текст с възможности: "march", "april", "may", "june", "july", "august"
  14. • На втория ред - броят на прекараните часове - цяло число в диапазона [1...10]
  15. • На третия ред - броят на хората в групата - цяло число в диапазона [1...10]
  16. • На четвъртия ред - времето от деня – текст с възможности: "day" или "night"
  17. Изход:
  18. Да се отпечатат на конзолата 2 реда:
  19. • На първия ред: "Price per person for one hour: {цена на човек за час}"
  20. • На втория ред: "Total cost of the visit: {общата цена}"
  21. Цените да бъдат форматирани до втория знак след десетичната запетая.
  22.  
  23. Примерен вход и изход:
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. package programmingBasics;
  34.  
  35. import java.util.Scanner;
  36.  
  37. public class ComputerRoom {
  38. public static void main(String[] args) {
  39. Scanner scanner = new Scanner(System.in);
  40. String month = scanner.nextLine();
  41. int hours = Integer.parseInt(scanner.nextLine());
  42. int people = Integer.parseInt(scanner.nextLine());
  43. String time = scanner.nextLine();
  44. double price = 0;
  45. double priceCount = 0;
  46. if (time.equals("day")) {
  47. if (month.equals("march")) {
  48. price = 10.50;
  49. priceCount = price * people * hours;
  50. System.out.printf("Price per person for one hour: %.2f %n", price);
  51. System.out.printf("Total cost of the visit: %.2f", priceCount);
  52.  
  53.  
  54. } else if (month.equals("april")) {
  55. price = 10.50;
  56. priceCount = price * people * hours;
  57. System.out.printf("Price per person for one hour: %.2f %n", price);
  58. System.out.printf("Total cost of the visit: %.2f", priceCount);
  59. } else if (month.equals("may")) {
  60. price = 10.50;
  61. priceCount = price * people * hours;
  62. System.out.printf("Price per person for one hour: %.2f %n", price);
  63. System.out.printf("Total cost of the visit: %.2f", priceCount);
  64.  
  65. }
  66. if (time.equals("night")) {
  67. if (month.equals("march")) {
  68. price = 8.40;
  69. priceCount = price * people * hours;
  70. System.out.printf("Price per person for one hour: %.2f %n", price);
  71. System.out.printf("Total cost of the visit: %.2f", priceCount);
  72. } else if (month.equals("april")) {
  73. price = 8.40;
  74. priceCount = price * people * hours;
  75. } else if (month.equals("may")) {
  76. price = 8.40;
  77. priceCount = price * people * hours;
  78. }
  79. if (time.equals("day")) {
  80. if (month.equals("june")) {
  81. price = 12.60;
  82. priceCount = price * people * hours;
  83. System.out.printf("Price per person for one hour: %.2f %n", price);
  84. System.out.printf("Total cost of the visit: %.2f", priceCount);
  85. } else if (month.equals("july")) {
  86. price = 12.60;
  87. priceCount = price * people * hours;
  88. System.out.printf("Price per person for one hour: %.2f %n", price);
  89. System.out.printf("Total cost of the visit: %.2f", priceCount);
  90. } else if (month.equals("august")) {
  91. price = 12.60;
  92. priceCount = price * people * hours;
  93. System.out.printf("Price per person for one hour: %.2f %n", price);
  94. System.out.printf("Total cost of the visit: %.2f", priceCount);
  95.  
  96. }
  97. if (time.equals("night")) {
  98. if (month.equals("june")) {
  99. ;
  100. price = 10.20;
  101. priceCount = price * people * hours;
  102. System.out.printf("Price per person for one hour: %.2f %n", price);
  103. System.out.printf("Total cost of the visit: %.2f", priceCount);
  104. } else if (month.equals("july")) {
  105. price = 10.20;
  106. priceCount = price * people * hours;
  107. System.out.printf("Price per person for one hour: %.2f %n", price);
  108. System.out.printf("Total cost of the visit: %.2f", priceCount);
  109. } else if (month.equals("august")) {
  110. price = 10.20;
  111. priceCount = price * people * hours;
  112. System.out.printf("Price per person for one hour: %.2f %n", price);
  113. System.out.printf("Total cost of the visit: %.2f", priceCount);
  114. }
  115.  
  116. }
  117. }
  118. }
  119.  
  120. }
  121. }
  122. }
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement