Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class ass2 {
- public static void main(String[] args)
- throws IOException
- {
- BufferedReader nameIn = new BufferedReader(new InputStreamReader (System.in));
- BufferedReader balIn = new BufferedReader(new InputStreamReader (System.in));
- BufferedReader monthlyIn = new BufferedReader(new InputStreamReader (System.in));
- BufferedReader intrIn = new BufferedReader(new InputStreamReader (System.in));
- BufferedReader timeIn = new BufferedReader(new InputStreamReader (System.in));
- String name, bal, monthly, time,interest;
- double douBal, douMonthly, douInterest;
- int x;
- boolean asd = false;
- System.out.println("Enter your full Name.");
- name = nameIn.readLine();
- while( asd = false)
- {
- System.out.println("Enter your Starting balance.");
- bal = balIn.readLine();
- douBal = Double.parseDouble(bal);
- if( douBal > 0)
- asd = true;
- {
- System.out.println("Enter your Monthly deposit amount.");
- monthly = monthlyIn.readLine();
- douMonthly = Double.parseDouble(monthly);
- System.out.println("Enter your Interest Rate.");
- interest = intrIn.readLine();
- douInterest = Double.parseDouble(interest);
- System.out.println("Enter The amount of Months");
- time = timeIn.readLine();
- x = Integer.parseInt(time);
- double startingBal;
- int i = 1;
- double balance, intrestEarned;
- balance = douBal;
- String[] temp = name.split(" ");
- char First = temp[0].charAt(0);
- System.out.println("Savings growth over the next 6 months for " + temp[1] + ", " + First + " :");
- System.out.printf("%n");
- while(i <= x)
- {
- balance = balance + douMonthly;
- intrestEarned = balance * ((douInterest/12)/100);
- balance = intrestEarned + balance;
- System.out.print("Balance after Month " + i + ": ");
- System.out.printf("%4.2f %n",balance);
- System.out.printf("Interest earned for this month: %2.2f %n",intrestEarned);
- System.out.printf("%n");
- i++;
- }
- balance = douBal;
- intrestEarned = 0;
- i = 1;
- System.out.print("Month New Balance Interest Earned");
- System.out.printf("%n");
- System.out.print("----- ----------- ---------------");
- System.out.printf("%n");
- while(i <= x)
- {
- balance = balance + douMonthly;
- intrestEarned = balance * ((douInterest/12)/100);
- balance = intrestEarned + balance;
- System.out.printf("%5d %11.2f %15.2f",i,balance,intrestEarned);
- System.out.printf("%n");
- i++;
- }
- }
- }
Add Comment
Please, Sign In to add comment