Advertisement
markopizzy

Untitled

Jan 16th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class JF_3_Vacation {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int peopleNum = Integer.parseInt(scanner.nextLine());
  8. String typePeople = scanner.nextLine();
  9. String day = scanner.nextLine();
  10.  
  11. double price = 0;
  12.  
  13. switch (typePeople) {
  14. case "Students":
  15. if ("Friday".equals(day)) {
  16. price = 8.45;
  17. } else if ("Saturday".equals(day)) {
  18. price = 9.80;
  19. } else if ("Sunday".equals(day)) {
  20. price = 10.46;
  21. }
  22. break;
  23. case "Business":
  24. if ("Friday".equals(day)) {
  25. price = 10.90;
  26. } else if ("Saturday".equals(day)) {
  27. price = 15.60;
  28. } else if ("Sunday".equals(day)) {
  29. price = 16;
  30. }
  31. break;
  32. case "Regular":
  33. if ("Friday".equals(day)) {
  34. price = 15;
  35. } else if ("Saturday".equals(day)) {
  36. price = 20.00;
  37. } else if ("Sunday".equals(day)) {
  38. price = 22.50;
  39. }
  40. break;
  41. }
  42. double subTotal = peopleNum * price;
  43. if ("Students".equals(typePeople) && peopleNum >= 30) {
  44. subTotal *= 0.85;
  45. }
  46. else if ("Business".equals(typePeople) && peopleNum >= 100) {
  47. subTotal *= 0.9;
  48. }
  49. else if ("Regular".equals(typePeople) && peopleNum >= 10 && peopleNum <= 20) {
  50. subTotal *= 0.95;
  51. }
  52. System.out.printf("Total price: %.2f", subTotal);
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement