Advertisement
Valeri12580

Tech Module-Vacation

Jan 25th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Vacantion {
  4. public static void main(String[] args) {
  5. Scanner scanner=new Scanner(System.in);
  6. int number=Integer.parseInt(scanner.nextLine());
  7. String typeGroup=scanner.nextLine();
  8. String dayWeek=scanner.nextLine();
  9. System.out.printf("Total price: %.2f", gettingPrice(typeGroup, dayWeek, number));
  10.  
  11. }
  12.  
  13. public static double gettingPrice(String typeGroup,String dayWeek,int number){
  14. double price=0;
  15. double totalPrice=0;
  16. boolean isStudents=false;
  17. boolean isBusiness=false;
  18. boolean isRegular=false;
  19. switch (typeGroup){ //vzimane na grupa
  20. case "Students":
  21. switch (dayWeek){
  22. case "Friday":
  23. price=8.45;
  24. break;
  25. case "Saturday":
  26. price=9.80;
  27. break;
  28. case "Sunday":
  29. price=10.46;
  30. break;
  31. }
  32. isStudents=true;
  33. break;
  34. case "Business":
  35. switch (dayWeek){
  36. case "Friday":
  37. price=10.90;
  38. break;
  39. case "Saturday":
  40. price=15.60;
  41. break;
  42. case "Sunday":
  43. price=16;
  44. break;
  45. }
  46. isBusiness=true;
  47. break;
  48. case "Regular":
  49. switch (dayWeek){
  50. case "Friday":
  51. price=15;
  52. break;
  53. case "Saturday":
  54. price=20;
  55. break;
  56. case "Sunday":
  57. price=22.50;
  58. break;
  59. }
  60. isRegular=true;
  61. break;
  62. }
  63. totalPrice=price*number;
  64. if (isStudents){
  65. if (number>=30) {
  66. totalPrice=totalPrice-(totalPrice*15/100);
  67. }
  68. } else if (isBusiness) {
  69. if (number>=100) {
  70. price*=10;
  71. totalPrice-=price;
  72.  
  73. }
  74. }else{
  75. if (number>=10 && number<=20){
  76. totalPrice=totalPrice-(totalPrice*0.05);
  77. }
  78. }
  79.  
  80. return totalPrice;
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement