Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TestJan;
- import java.util.Scanner;
- public class Rate {
- 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 simpleSum = 0;
- double complicatedSum = 0;
- double sum1 = S;
- double sum2 = S;
- for (int i = 0; i < months; i++) {
- sum1 += 0.03 * S;
- sum2 += 0.027 * sum2;
- }
- simpleSum += sum1;
- complicatedSum += sum2;
- System.out.printf("Simple interest rate: %.2f lv.%n",simpleSum);
- System.out.printf("Complex interest rate: %.2f lv.%n",complicatedSum);
- if (simpleSum > complicatedSum) {
- System.out.printf("Choose a simple interest rate. You will win %.2f lv.%n",simpleSum-complicatedSum);
- } else if (simpleSum < complicatedSum) {
- System.out.printf("Choose a complex interest rate. You will win %.2f lv.%n",complicatedSum-simpleSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement