Advertisement
myrdok123

Deposit Calculator

Oct 2nd, 2022
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. package FirstStepsInCoding.Exercise;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class DepositCalculator {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner scanner = new Scanner(System.in);
  10.  
  11.         //прочитаме от конзолата входните данни
  12.         double depositAmount = Double.parseDouble(scanner.nextLine());
  13.         int months = Integer.parseInt(scanner.nextLine());
  14.         double interestRate = Double.parseDouble(scanner.nextLine());
  15.  
  16.         //пресмятаме стойността за месец
  17.         double profitPerMonth = (depositAmount * (interestRate/100))/12;
  18.  
  19.         //пресмятаме цялата сума за всички месеци
  20.         double totalSum = depositAmount + profitPerMonth * months;
  21.         //принтиране на конзолата
  22.         System.out.println(totalSum);
  23.  
  24.  
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement