Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class calculator{
- private double interest_principal, month_interest, interest_amount;
- private double principal = 1000;
- private int a, c;
- double cinterest (int x){
- interest_amount = Math.pow(1 + 2.65/100, x) - 1;
- return(interest_amount * principal);
- }
- }
- class intcalc{
- public static void main(String[] args){
- calculator interest = new calculator();
- Scanner uinput = new Scanner(System.in);
- int months[] = {2, 5, 10, 500};
- int user_months;
- for(int b=0;b<4;b++){
- System.out.println("Interest at " +
- months[b] + " months is: " + interest.cinterest(months[b]));
- }
- System.out.print("Enter # of months for interest calculation: ");
- user_months = uinput.nextInt();
- System.out.println("Interest amount after " + user_months + " months is: "
- + interest.cinterest(user_months));
- }
- }
Add Comment
Please, Sign In to add comment