Advertisement
desislava_topuzakova

04.Rate

Mar 11th, 2018
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. package TestJan;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Rate {
  6.     public static void main(String[] args) {
  7.  
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         double S = Double.parseDouble(scanner.nextLine());
  11.         int months = Integer.parseInt(scanner.nextLine());
  12.  
  13.         double simpleSum = 0;
  14.         double complicatedSum = 0;
  15.  
  16.         double sum1 = S;
  17.         double sum2 = S;
  18.  
  19.         for (int i = 0; i < months; i++) {
  20.             sum1 += 0.03 * S;
  21.             sum2 += 0.027 * sum2;
  22.         }
  23.         simpleSum += sum1;
  24.         complicatedSum += sum2;
  25.  
  26.         System.out.printf("Simple interest rate: %.2f lv.%n",simpleSum);
  27.         System.out.printf("Complex interest rate: %.2f lv.%n",complicatedSum);
  28.  
  29.  
  30.         if (simpleSum > complicatedSum) {
  31.             System.out.printf("Choose a simple interest rate. You will win %.2f lv.%n",simpleSum-complicatedSum);
  32.         } else if (simpleSum < complicatedSum) {
  33.             System.out.printf("Choose a complex interest rate. You will win %.2f lv.%n",complicatedSum-simpleSum);
  34.         }
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement