Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Ex3 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double S = Double.parseDouble(scanner.nextLine());
- int months = Integer.parseInt(scanner.nextLine());
- double simple = S;
- double complex = S;
- double currentSimple = S;
- for (int i = 0; i < months ; i++) {
- simple += currentSimple*0.03;
- }
- for (int i = 0; i < months; i++) {
- complex += complex*0.027;
- }
- if (simple>complex){
- 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);
- }else if (complex>simple){
- 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);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement