yovkovbpfps

EXAM 2-3 MAY 2019 03.Mobile Operator

May 7th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MobileOperator {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String contractLength = scanner.nextLine();
  8. String contractType = scanner.nextLine();
  9. String addonInet = scanner.nextLine();
  10. int months = Integer.parseInt(scanner.nextLine());
  11.  
  12. double price = 0;
  13.  
  14. if (contractLength.equals("one")) {
  15. switch (contractType) {
  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. }
  30. else
  31. {
  32. switch (contractType)
  33. {
  34. case "Small":
  35. price = 8.58;
  36. break;
  37. case "Middle":
  38. price = 17.09;
  39. break;
  40. case "Large":
  41. price = 23.59;
  42. break;
  43. case "ExtraLarge":
  44. price = 31.79;
  45. break;
  46. }
  47. }
  48.  
  49. if (addonInet.equals("yes")) {
  50. if (price <= 10) {
  51. price += 5.50;
  52. }
  53. else if (price > 10 && price <= 30) {
  54. price += 4.35;
  55. }
  56. else if (price > 30) {
  57. price += 3.85;
  58. }
  59. }
  60. price *= months;
  61. if (contractLength.equals("two")) {
  62. price -= price * 0.0375;
  63. }
  64. System.out.printf("%.2f lv.", price);
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment