Advertisement
Guest User

Untitled

a guest
Mar 4th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 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.  
  10. double simple = S;
  11. double complex = S;
  12. double currentSimple = S;
  13.  
  14. for (int i = 0; i < months ; i++) {
  15. simple += currentSimple*0.03;
  16. }
  17.  
  18. for (int i = 0; i < months; i++) {
  19. complex += complex*0.027;
  20. }
  21.  
  22. if (simple>complex){
  23. System.out.printf("Simple interest rate: %.2f lv. %nComplex interest rate: %.2f lv.%n%nChoose a simple interest rate. You will win %.2f lv.", simple, complex, simple-complex);
  24. }else if (complex>simple){
  25. System.out.printf("Simple interest rate: %.2f lv. %nComplex interest rate: %.2f lv.%n%nChoose a complex interest rate. You will win %.2f lv.", simple, complex, complex-simple);
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement