Guest User

Untitled

a guest
Sep 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1.  
  2.  
  3. import java.io.*;
  4. public class ass2 {
  5. public static void main(String[] args)
  6. throws IOException
  7. {
  8. BufferedReader nameIn = new BufferedReader(new InputStreamReader (System.in));
  9. BufferedReader balIn = new BufferedReader(new InputStreamReader (System.in));
  10. BufferedReader monthlyIn = new BufferedReader(new InputStreamReader (System.in));
  11. BufferedReader intrIn = new BufferedReader(new InputStreamReader (System.in));
  12. BufferedReader timeIn = new BufferedReader(new InputStreamReader (System.in));
  13.  
  14. String name, bal, monthly, time,interest;
  15. double douBal, douMonthly, douInterest;
  16. int x;
  17. boolean asd = false;
  18.  
  19. System.out.println("Enter your full Name.");
  20. name = nameIn.readLine();
  21.  
  22. while( asd = false)
  23. {
  24. System.out.println("Enter your Starting balance.");
  25. bal = balIn.readLine();
  26. douBal = Double.parseDouble(bal);
  27. if( douBal > 0)
  28. asd = true;
  29. {
  30.  
  31. System.out.println("Enter your Monthly deposit amount.");
  32. monthly = monthlyIn.readLine();
  33. douMonthly = Double.parseDouble(monthly);
  34.  
  35.  
  36. System.out.println("Enter your Interest Rate.");
  37. interest = intrIn.readLine();
  38. douInterest = Double.parseDouble(interest);
  39.  
  40.  
  41. System.out.println("Enter The amount of Months");
  42. time = timeIn.readLine();
  43. x = Integer.parseInt(time);
  44.  
  45. double startingBal;
  46. int i = 1;
  47. double balance, intrestEarned;
  48. balance = douBal;
  49.  
  50. String[] temp = name.split(" ");
  51. char First = temp[0].charAt(0);
  52. System.out.println("Savings growth over the next 6 months for " + temp[1] + ", " + First + " :");
  53. System.out.printf("%n");
  54.  
  55. while(i <= x)
  56. {
  57. balance = balance + douMonthly;
  58. intrestEarned = balance * ((douInterest/12)/100);
  59. balance = intrestEarned + balance;
  60. System.out.print("Balance after Month " + i + ": ");
  61. System.out.printf("%4.2f %n",balance);
  62. System.out.printf("Interest earned for this month: %2.2f %n",intrestEarned);
  63. System.out.printf("%n");
  64. i++;
  65.  
  66. }
  67. balance = douBal;
  68. intrestEarned = 0;
  69. i = 1;
  70.  
  71. System.out.print("Month New Balance Interest Earned");
  72. System.out.printf("%n");
  73. System.out.print("----- ----------- ---------------");
  74. System.out.printf("%n");
  75.  
  76.  
  77. while(i <= x)
  78. {
  79. balance = balance + douMonthly;
  80. intrestEarned = balance * ((douInterest/12)/100);
  81. balance = intrestEarned + balance;
  82. System.out.printf("%5d %11.2f %15.2f",i,balance,intrestEarned);
  83. System.out.printf("%n");
  84. i++;
  85. }
  86.  
  87. }
  88. }
Add Comment
Please, Sign In to add comment