Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TravelAgency {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String city = scanner.nextLine();
  8. String packet = scanner.nextLine();
  9. String VIP = scanner.nextLine();
  10. int days = Integer.parseInt(scanner.nextLine());
  11.  
  12. double price = 0;
  13.  
  14. if ((city.equals("Bansko") || city.equals("Borovets")) && days > 0) {
  15. if (packet.equals("noEquipment")) {
  16. price = days * 80;
  17. if (VIP.equals("yes")) {
  18. price = price * 0.95;
  19. }if (days>7){
  20. price = price - price /days;
  21. }
  22. } else if (packet.equals("withEquipment")) {
  23. price = days * 100;
  24. if (VIP.equals("yes")) {
  25. price = price * 0.9;
  26. }else if (days>7){
  27. price = price - price/days;
  28. }
  29. } else {
  30. System.out.println("Invalid input!");
  31. }
  32. System.out.printf("The price is %.2flv! Have a nice time!", price);
  33. } else if ((city.equals("Varna") || city.equals("Burgas")) && days > 0) {
  34. if (packet.equals("withBreakfast")) {
  35. price = days * 130;
  36. if (VIP.equals("yes")) {
  37. price = price * 0.88;
  38. }else if (days>7){
  39. price = price - price/days;
  40. }
  41. System.out.printf("The price is %.2flv! Have a nice time!", price);
  42. } else if (packet.equals("noBreakfast")) {
  43. price = days * 100;
  44. if (VIP.equals("yes")) {
  45. price = price * 0.93;
  46. }else if (days>7){
  47. price = price - price/days;
  48. }
  49. System.out.printf("The price is %.2flv! Have a nice time!", price);
  50. } else{
  51. System.out.println("Invalid input!");
  52. }
  53. } else if (days <= 0) {
  54. System.out.println("Days must be positive number!");
  55. } else{
  56. System.out.println("Invalid input!");
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement