Advertisement
Guest User

Untitled

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