SHARE
TWEET

01. Savings

desislava_topuzakova Jun 6th, 2020 831 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top