Advertisement
bobski1617

Untitled

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