Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. // Christian Grant
  2. // CIS 150AB 31662
  3. // Business P4.9 Online Bank
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class OnlineBank
  8. {
  9. public static void main(String[] args)
  10. {
  11. // Instantiate the input system
  12. Scanner in = new Scanner(System.in);
  13.  
  14. // Grab the initial balance from the user
  15. System.out.print("Initial balance: ");
  16. double initialBalance = in.nextDouble();
  17.  
  18. // Grab the interest from the user
  19. System.out.print("Annual interest rate in percent: ");
  20. double initialInterest = in.nextDouble();
  21.  
  22. // Compute the annual interest
  23. double interest = initialInterest / 100;
  24.  
  25. // Compute the monthly interest
  26. double monthlyInterest = interest / 12;
  27.  
  28. // Compute the first month with interest
  29. double firstInterest = initialBalance * monthlyInterest;
  30. double firstCompound = firstInterest + initialBalance;
  31.  
  32. // Compute the second month with compound interest
  33. double secondInterest = firstCompound * monthlyInterest;
  34. double secondCompound = secondInterest + firstCompound;
  35.  
  36. // Computer the third month with compound interest
  37. double thirdInterest = secondCompound * monthlyInterest;
  38. double thirdCompound = thirdInterest + secondCompound;
  39.  
  40.  
  41. // Output the compounded interest for the first three months
  42. System.out.printf("After first month: %.2f", firstCompound);
  43. System.out.printf("\nAfter second month: %.2f", secondCompound);
  44. System.out.printf("\nAfter third month: %.2f", thirdCompound);
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement