Advertisement
mcnealk

Project2

Oct 6th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. import java.util.*;
  2. /**
  3. * Write a description of class Project2 here.
  4. * Kailey McNeal
  5. * 10-2-14
  6. * Project #2
  7. */
  8. public class Project2
  9. {
  10. public static void main (String[] args)
  11. {
  12. Scanner console=new Scanner (System.in);
  13. System.out.print("Interest Rate: ");
  14. double percent=console.nextDouble();
  15. System.out.print("Initial Deposit: ");
  16. double initial=console.nextDouble();
  17. System.out.print("Time(Years) : ");
  18. int years=console.nextInt();
  19. System.out.print("New Deposit: ");
  20. double extra=console.nextDouble();
  21. header();
  22. for (int i=1; i<=years; i++) //year
  23. {
  24. double rate=(percent/100);
  25. double interest = (initial*rate);
  26. interest=(Math.round(interest*100))/100;
  27. double balance=interest + initial;
  28. balance=Math.round(balance*100)/100;
  29. double newbalance=balance+extra;
  30. System.out.println("|\t" + i + "\t|\t" + initial + "\t|\t" + interest + "\t|\t" + balance + "\t|\t" + extra + "\t|" + "\t|\t" + newbalance + "\t|");
  31. initial=newbalance;
  32. }
  33. }
  34. public static void header()
  35. {
  36. System.out.println("|\tYears\t|\tDeposit|\tInterest|\tBalance|\tExtra Deposit\t|\tNew Balance\t|");
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement