Advertisement
veronikaaa86

03. Mobile operator

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