bobski1617

Untitled

Sep 8th, 2021
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class phoneBill {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String input = scanner.nextLine();
  8. int messages = Integer.parseInt(input);
  9. input = scanner.nextLine();
  10. int minutes = Integer.parseInt(input);
  11.  
  12. double extraMessages = 0;
  13. if (messages>20){
  14. extraMessages = messages - 20;
  15. }
  16.  
  17. double extraMinutes = 0;
  18. if (minutes>60){
  19. extraMinutes = minutes - 60;
  20. }
  21.  
  22. double messagesPrice = extraMessages * 0.06;
  23. double minutesPrice = extraMinutes * 0.1;
  24. double tax = (messagesPrice + minutesPrice) * 0.2;
  25. double totalBill = messagesPrice + minutesPrice + tax + 12;
  26.  
  27. System.out.printf("%.0f additional messages for %.2f levas%n", extraMessages, messagesPrice);
  28. System.out.printf("%.0f additional minutes for %.2f levas%n", extraMinutes, minutesPrice);
  29. System.out.printf("%.2f additional taxex%n", tax);
  30. System.out.printf("%.2f total bill%n", totalBill);
  31.  
  32. }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment