Guest User

Untitled

a guest
Aug 24th, 2020
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.telerikacademy;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class PhoneBill {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         Integer totalAmountOfMessages = Integer.parseInt(scanner.nextLine());
  10.         Integer totalAmountOfMinutes = Integer.parseInt(scanner.nextLine());
  11.  
  12.         Double planTaxes = 12.00;
  13.         Double minuteCost = 0.10;
  14.         Double messagePrice = 0.06;
  15.  
  16.         Integer additionalMessage = 0;
  17.         Integer additionalMinutes = 0;
  18.         Double priceForAdditionalMessages;
  19.         Double priceForAdditionalMinutes;
  20.         Double additionalTaxesPaid;
  21.         Double finalPrice;
  22.  
  23.         if (totalAmountOfMessages > 20 && totalAmountOfMinutes > 60) {
  24.             additionalMessage = totalAmountOfMessages - 20;
  25.             priceForAdditionalMessages = messagePrice * additionalMessage;
  26.             System.out.printf("%d additional messages for %.2f levas%n", additionalMessage, priceForAdditionalMessages);
  27.  
  28.             additionalMinutes = totalAmountOfMinutes - 60;
  29.             priceForAdditionalMinutes = minuteCost * additionalMinutes;
  30.             System.out.printf("%d additional minutes for %.2f levas%n", additionalMinutes, priceForAdditionalMinutes);
  31.  
  32.             additionalTaxesPaid = ((additionalMessage * messagePrice + additionalMinutes * minuteCost) / 100) * 20;
  33.             System.out.printf("%.2f additional taxes%n", additionalTaxesPaid);
  34.  
  35.             finalPrice = 12 + priceForAdditionalMessages + priceForAdditionalMinutes + additionalTaxesPaid;
  36.             System.out.printf("%.2f total bill", finalPrice);
  37.         } else if (totalAmountOfMessages > 20 && totalAmountOfMinutes < 60) {
  38.  
  39.             additionalMessage = totalAmountOfMessages - 20;
  40.             priceForAdditionalMessages = messagePrice * additionalMessage;
  41.             System.out.printf("%d additional messages for %.2f levas%n", additionalMessage, priceForAdditionalMessages);
  42.             System.out.println("0 additional minutes for 0.00 levas");
  43.  
  44.  
  45.             additionalTaxesPaid = ((additionalMessage * messagePrice) / 100) * 20;
  46.             System.out.printf("%.2f additional taxes%n", additionalTaxesPaid);
  47.  
  48.             finalPrice = 12 + priceForAdditionalMessages + additionalTaxesPaid;
  49.             System.out.printf("%.2f total bill", finalPrice);
  50.         } else if (totalAmountOfMessages < 20 && totalAmountOfMinutes > 60) {
  51.  
  52.             System.out.println("0 additional messages for 0.00 levas");
  53.  
  54.             additionalMinutes = totalAmountOfMinutes - 60;
  55.             priceForAdditionalMinutes = minuteCost * additionalMinutes;
  56.             System.out.printf("%d additional minutes for %.2f levas%n", additionalMinutes, priceForAdditionalMinutes);
  57.  
  58.  
  59.             additionalTaxesPaid = ((additionalMinutes * minuteCost) / 100) * 20;
  60.             System.out.printf("%.2f additional taxes%n", additionalTaxesPaid);
  61.  
  62.             finalPrice = 12 + +priceForAdditionalMinutes + additionalTaxesPaid;
  63.             System.out.printf("%.2f total bill", finalPrice);
  64.         } else {
  65.             System.out.println("0 additional messages for 0.00 levas");
  66.             System.out.println("0 additional minutes for 0.00 levas");
  67.             System.out.println("0.00 additional taxes");
  68.             System.out.println("12.00 total bill");
  69.         }
  70.  
  71.     }
  72. }
  73.  
RAW Paste Data