Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MyClass {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String contractTerm = scanner.nextLine();
- String contractType = scanner.nextLine();
- String mobileInternet = scanner.nextLine();
- int months = scanner.nextInt();
- double basePrice = 0;
- double internetPrice = 0;
- double totalDiscount = 1;
- switch (contractTerm) {
- case "one":
- switch (contractType) {
- case "Small":
- basePrice = 9.98;
- break;
- case "Middle":
- basePrice = 18.99;
- break;
- case "Large":
- basePrice = 25.98;
- break;
- case "ExtraLarge":
- basePrice = 35.99;
- break;
- }
- break;
- case "two":
- switch (contractType) {
- case "Small":
- basePrice = 8.58;
- break;
- case "Middle":
- basePrice = 17.09;
- break;
- case "Large":
- basePrice = 23.59;
- break;
- case "ExtraLarge":
- basePrice = 31.79;
- break;
- }
- totalDiscount -= 0.0375;
- break;
- }
- if (mobileInternet.equals("yes")) {
- if (basePrice <= 10) {
- internetPrice = 5.50;
- } else if (basePrice <= 30) {
- internetPrice = 4.35;
- } else {
- internetPrice = 3.85;
- }
- }
- double totalPrice = (basePrice + internetPrice) * months * totalDiscount;
- System.out.printf("%.2f lv.", totalPrice);
- }
- }
Add Comment
Please, Sign In to add comment