Advertisement
desislava_topuzakova

01. Savings

Jun 6th, 2020
1,360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class demo {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double income = Double.parseDouble(scanner.nextLine());
  7.         int months = Integer.parseInt(scanner.nextLine());
  8.         double sumPrivateExpenses = Double.parseDouble(scanner.nextLine());
  9.         //доход = лични разходи + непредвидени разходи + спестени пари -> за 1 месец
  10.         //спестени пари = дохода - пари за лични разходи - пари за непредвидени разходи
  11.         double sumUnexpectedExpenses = 0.3 * income;
  12.         double savedMoneyPerMonth = income - sumPrivateExpenses - sumUnexpectedExpenses;
  13.         double savedMoney = months * savedMoneyPerMonth; //спестени пари за всички месеци
  14.         double percent = savedMoneyPerMonth / income * 100;
  15.  
  16.         System.out.printf("She can save %.2f%%%n", percent);
  17.         System.out.printf("%.2f", savedMoney);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement