class saving{
public static void main(String arg[]) throws IOException {
BufferedReader stdin =
new BufferedReader ( new InputStreamReader (System.in));
DecimalFormat twoDigitsPastPoint = new DecimalFormat("0.00");
// Variables Declation
String get_P_Balance, get_P_Interest, get_No_Years;
String get_P_Balance2, get_P_Interest2, get_No_Years2;
String answer;
double n_Number_Years=0;
double n_P_Balance=0.00, n_P_Interest=0.00;
double n_Final_Solve=0.00;
int a=0;
char reply;
System.out.print("\n\t =========================================");
System.out.print("\n\t ==Savings Quickie Version 1.0===");
System.out.print("\n\t =========================================");
System.out.print("\n\n");
System.out.print("ENTER PRESENT SAVINGS BALANCE :=> $ ");
get_P_Balance= stdin.readLine();
n_P_Balance = Double.parseDouble(get_P_Balance);
System.out.print("ENTER INTEREST RATE PERCENT :=> ");
get_P_Interest= stdin.readLine();
n_P_Interest = Double.parseDouble(get_P_Interest);
System.out.print("ENTER NUMBER OF YEARS :=> ");
get_No_Years= stdin.readLine();
n_Number_Years = Double.parseDouble(get_No_Years);
System.out.print("\n");
System.out.print(" === COMPUTED RESULTS === ");
System.out.print("\n\n");
for (a=1; a<= n_Number_Years; a++) {
n_Final_Solve =n_Final_Solve + n_P_Interest * (n_Final_Solve + n_P_Balance) /100;
System.out.println("Year No. "+ a + " => $ " + twoDigitsPastPoint.format(n_Final_Solve + n_P_Balance) + ".");
}
do {
System.out.print("\n\n");
System.out.print("DO YOU WANT TO continue Y/N => ");
answer = stdin.readLine();
reply = answer.charAt(0);
if (reply =='n' || reply=='N')
{
System.out.print("\n\n");
System.out.print("\t\t===================================================== " );
System.out.println("\n\t\t\t THANK YOU for USING this PROGRAM" );
System.out.println("\t\t Program Coding & Design By: Jake Rodriguez Pomperada " );
System.out.print("\t\t===================================================== " );
System.out.print("\n\n");
System.exit(0);
}
else if (reply =='Y' || reply=='y')
{
// Second Part of the Code for Continuat
// ion of the execution of the code
// to prevent errorneous computation if
// you call again the main code of
// the program you must assign a new var
// iable to avoid such problem.
double n_P_Balance2=0.00, n_P_Interest2=0.00;
double n_Final_Solve2=0.00;
double n_Number_Years2=0;
int a2=0;
System.out.print("\n\n");
System.out.print("\n\t =========================================");
System.out.print("\n\t ==Savings Quikie Version 1.0===");
System.out.print("\n\t =========================================");
System.out.print("\n\n");
System.out.print("ENTER PRESENT SAVINGS BALANCE :=> $ ");
get_P_Balance2= stdin.readLine();
n_P_Balance2 = Double.parseDouble(get_P_Balance2);
System.out.print("ENTER INTEREST RATE PERCENT :=> ");
get_P_Interest2= stdin.readLine();
n_P_Interest2 = Double.parseDouble(get_P_Interest2);
System.out.print("ENTER NUMBER OF YEARS :=> ");
get_No_Years2= stdin.readLine();
n_Number_Years2 = Double.parseDouble(get_No_Years2);
System.out.print("\n");
System.out.print(" === COMPUTED RESULTS === ");
System.out.print("\n\n");
for (a2=1; a2<= n_Number_Years2; a2++) {
n_Final_Solve2 =n_Final_Solve2 + n_P_Interest2 * (n_Final_Solve2 + n_P_Balance2) /100;
System.out.println("Year No. "+ a2 + " => $ " + twoDigitsPastPoint.format(n_Final_Solve2 + n_P_Balance2) + ".");
}
}
} while (reply== 'Y' || reply == 'y');
}
} // End of Code
Mod edit: added code tags:

New Topic/Question
Reply




MultiQuote



|