grach

exam_Preparation

May 1st, 2020
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Saving {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         double income = Double.parseDouble(scan.nextLine());
  8.         int mounts = Integer.parseInt(scan.nextLine());
  9.  
  10.         double moneyToLive = Double.parseDouble(scan.nextLine());
  11.         double guarantee = income*0.3;
  12.  
  13.         double untouchable = guarantee+moneyToLive;
  14.  
  15.         double save = 0;
  16.         int counter = 0;
  17.  
  18.         for (int i = 1; i <= mounts ; i++) {
  19.             save=income-(untouchable);
  20.             counter++;
  21.         }
  22.         System.out.printf("She can save %.2f%%%n", save/income*100);
  23.         System.out.printf("%.2f",save*counter);
  24.        
  25.  
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment