myrdok123

03. Deposit Calculator

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