desislava_topuzakova

Untitled

Oct 19th, 2021
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P03_MobileOperator {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. String period = scan.nextLine();
  8. String type = scan.nextLine();
  9. String internet = scan.nextLine();
  10. int mothsToPay = Integer.parseInt(scan.nextLine());
  11.  
  12. double price = 0.0;
  13.  
  14. if ("one".equals(period)) {
  15. switch (type) {
  16. case "Small":
  17. price = 9.98;
  18. break;
  19. case "Middle":
  20. price = 18.99;
  21. break;
  22. case "Large":
  23. price = 25.98;
  24. break;
  25. case "ExtraLarge":
  26. price = 35.99;
  27. break;
  28. }
  29. } else if ("two".equals(period)) {
  30. switch (type) {
  31. case "Small":
  32. price = 8.58;
  33. break;
  34. case "Middle":
  35. price = 17.09;
  36. break;
  37. case "Large":
  38. price = 23.59;
  39. break;
  40. case "ExtraLarge":
  41. price = 31.79;
  42. break;
  43. }
  44. }
  45. if ("yes".equals(internet)) {
  46. if (price <= 10) {
  47. price += 5.50;
  48. } else if (price <= 30) {
  49. price += 4.35;
  50. } else {
  51. price += 3.85;
  52. }
  53. }
  54.  
  55. price *= mothsToPay;
  56.  
  57. if ("two".equals(period)) {
  58. price -= price * 0.0375;
  59. }
  60.  
  61. System.out.println(String.format("%.2f lv.", price));
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment