galinyotsev123

ProgBasicsExam11and12August2018-E03computerRoom

Jan 2nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E03computerRoom {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7.  
  8.  
  9. String month = scanner.nextLine();
  10. double hours = Double.parseDouble(scanner.nextLine());
  11. double people = Double.parseDouble(scanner.nextLine());
  12. String dayTime = scanner.nextLine();
  13.  
  14. double price = 0;
  15. double totalSum = 0;
  16.  
  17. switch (month)
  18. {
  19. case "march":
  20. case "april":
  21. case "may":
  22. if (dayTime.equalsIgnoreCase("day")){
  23. price = 10.50;
  24. }
  25. else if (dayTime.equalsIgnoreCase("night")){
  26. price = 8.40;
  27. }
  28. break;
  29.  
  30. case "june":
  31. case "july":
  32. case "august":
  33. if (dayTime.equalsIgnoreCase("day")){
  34. price = 12.60;
  35. }
  36. else if (dayTime.equalsIgnoreCase("night")){
  37. price = 10.20;
  38. }
  39. break;
  40. }
  41.  
  42. if (people >= 4)
  43. {
  44. price *= 0.9;
  45. }
  46.  
  47. if (hours >= 5)
  48. {
  49. price *= 0.5;
  50. }
  51.  
  52. totalSum = price * people*hours;
  53.  
  54. System.out.printf("Price per person for one hour: %.2f%n", price);
  55. System.out.printf("Total cost of the visit: %.2f", totalSum);
  56.  
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment