Advertisement
cvet40

School Camp

Mar 3rd, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. package Z_Exams03;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class SchoolCamp {
  6. public static void main(String[] args) {
  7. Scanner scan = new Scanner(System.in);
  8. String season = scan.nextLine().toLowerCase(); // winter , summer , spring
  9. String group = scan.nextLine().toLowerCase(); // boys , girls , mixed
  10. int studentNum = Integer.parseInt(scan.nextLine());
  11. int nights = Integer.parseInt(scan.nextLine());
  12.  
  13. double priceForNight = 0;
  14.  
  15. String sport = "";
  16.  
  17. switch (season) {
  18. case "winter":
  19. switch (group) {
  20. case "boys":
  21. sport = "Judo";
  22. priceForNight = 9.60;
  23. break;
  24. case "girls":
  25. sport = "Gymnastics";
  26. priceForNight = 9.60;
  27. break;
  28. case "mixed":
  29. sport = "Ski";
  30. priceForNight = 10;
  31. break;
  32. }
  33. break;
  34. case "summer":
  35. switch (group) {
  36. case "boys":
  37. sport = "Football";
  38. priceForNight = 15;
  39. break;
  40. case "girls":
  41. sport = "Volleyball";
  42. priceForNight = 15;
  43. break;
  44. case "mixed":
  45. sport = "Swimming";
  46. priceForNight = 20;
  47. break;
  48. }
  49. break;
  50. case "spring":
  51. switch (group) {
  52. case "boys":
  53. sport = "Tennis";
  54. priceForNight = 7.20;
  55. break;
  56. case "girls":
  57. sport = "Athletics";
  58. priceForNight = 7.20;
  59. break;
  60. case "mixed":
  61. sport = "Cycling";
  62. priceForNight = 9.50;
  63. break;
  64. }
  65. break;
  66. }
  67. double sum = studentNum * nights * priceForNight;
  68. if (studentNum >= 10 && studentNum < 20) {
  69. System.out.printf("%s %.2f lv.", sport, sum * (1 - 0.05));
  70. } else if (studentNum >= 20 && studentNum < 50) {
  71. System.out.printf("%s %.2f lv.", sport, sum * (1 - 0.15));
  72. } else if (studentNum >= 50) {
  73. System.out.printf("%s %.2f lv.", sport, sum * (1 - 0.5));
  74. }else {
  75. System.out.printf("%s %.2f lv.", sport, sum );
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement