Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1.  
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         Scanner scanner = new Scanner(System.in);
  5.  
  6.         int months = Integer.parseInt(scanner.nextLine());
  7.         int percent = Integer.parseInt(scanner.nextLine());
  8.         double rent = Double.parseDouble(scanner.nextLine());
  9.  
  10.         int halfMonths = months / 2;
  11.         double halfSum = rent * halfMonths;
  12.  
  13.         int secondHalf = months - halfMonths;
  14.         double secondSum = (rent - (rent * (20 / 100.0))) * secondHalf;
  15.  
  16.         double totalSum = halfSum + secondSum;
  17.         double broker = totalSum * (percent / 100.0);
  18.         double totalSum2 = totalSum + broker;
  19.  
  20.         System.out.printf("Total: %.2f", totalSum2);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement