Advertisement
Stelios_Gakis

Seminar_2/Task_2

Sep 25th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. package Seminar_2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Task_2 {
  6.  
  7.     private static final Scanner in = new Scanner(System.in);
  8.  
  9.  
  10.  
  11.     public static void main(String [] args) {
  12.         Task_2 myApp = new Task_2();
  13.         System.out.print("Please enter your current balance : ");
  14.         double balance = in.nextDouble();
  15.         for (int i = 0; i < 9; i++) {
  16.             double interestRate = i + 2;
  17.             myApp.interestRate(balance, interestRate);
  18.             System.out.printf("--- --- ---");
  19.         }
  20.     }
  21.  
  22.     private void interestRate(double balance, double interest) {
  23.         double newBalance = balance + balance * interest / 100;
  24.         char percent = '%';
  25.         System.out.printf("--- --- ---%nInitial amount         : %.2f%nInterest rate          : %.2f%c%nBalance after one year : %.2f%n", balance, interest, percent, newBalance);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement