vladovip

Phone Bill - Java_ alpha preparation

Jan 15th, 2022
761
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class phoneBill {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner input = new Scanner(System.in);
  9.         String line1 = input.nextLine();
  10.         String line2 = input.nextLine();
  11.         int textMessages = Integer.parseInt(line1);
  12.         int totalMinutes = Integer.parseInt(line2);
  13.         int extraMessages = 0;
  14.         int extraMinutes = 0;
  15.  
  16.         if (textMessages > 20  ){
  17.             extraMessages = textMessages - 20;
  18.         }
  19.         if (totalMinutes>60 ){
  20.             extraMinutes = totalMinutes -60;
  21.         }
  22.  
  23.         double priceExtraMessages = extraMessages * 0.06;
  24.         double priceExtraMinutes = extraMinutes * 0.10;
  25.         double additionalTax= (priceExtraMessages+priceExtraMinutes)*0.20;
  26.         double totalAmountPaid= 12+ priceExtraMessages+priceExtraMinutes + additionalTax;
  27.  
  28.         System.out.printf("%d additional messages for %.2f levas",extraMessages,priceExtraMessages );
  29.         System.out.printf("%n%d additional minutes for %.2f levas", extraMinutes,priceExtraMinutes );
  30.         System.out.printf("%n%.2f additional taxes", additionalTax);
  31.         System.out.printf("%n%.2f total bill", totalAmountPaid);
  32.  
  33.     }
  34. }
  35.  
RAW Paste Data