Advertisement
Lyubohd

01. Savings

Feb 22nd, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Problem01 {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         double income = Double.parseDouble(scan.nextLine());
  7.         int months = Integer.parseInt(scan.nextLine());
  8.         double moneyNeedPerMonth = Double.parseDouble(scan.nextLine());
  9.  
  10.         double additionalCosts = income * 0.3; // income - income * 0.7;
  11.         double moneySavedPerMonth = income - additionalCosts - moneyNeedPerMonth;
  12.         double percentSavedMoney = moneySavedPerMonth / income * 100;
  13.  
  14.         double totalSavedMoney = moneySavedPerMonth * months;
  15.  
  16.         System.out.printf("She can save %.2f%%%n", percentSavedMoney);
  17.         System.out.printf("%.2f", totalSavedMoney);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement