I already have a Please Press Enter to continue... Statement for the end of my list that will allow the list to stay on the screen, be read, then when the user is ready they hit enter and the list continues to the next page. That is part of the assignment what I want to add is not part of the assignment but I think would be cool to learn. I would like to give the user the option of either Pressing Enter to Continue (have this) or to return to the main console, or to exit the program.

Do I use a series of IF statements, or If/else statements, is what I am looking for called something else?

I googled what I thought to as on how to do this but I still can't find anything.

Thanks for any help you can give.

*---------------------------------------------------------------------------*/
//                            PROGRAM INFORMATION
//                        Programmer : Mari Dutton
//
//  Date    : (8/14/2010)
//  Name    : MortgageCalculator
//  Filename: MortgageCalculator.java
//	Purpose : The purpose of this program is to calculate mortgage payments.
//			  To calculate and display the customer's monthly mortgage
//            of $200000 at 5.75% interest over 30 years.The program will display
// 			  360 payments with interest by the Month for 30 years.

//---------------------------------------------------------------------------*/

import java.text.DecimalFormat;//to import decimal format for money
import java.text.NumberFormat;//to import number format
import java.io.Console;//Calls the class Console for user input and output


 public class MortgageCalculator1 // Starts the Class
   {
 public static void main(String[]args) throws Exception //declaring main method with thrown Exception
      {

//Arrays
double   loanAmount = 200000; //Starting Balance of loan
double[] tMonths = {360,180,84};// Array for year term of the Loan
double[] iRate   = {.0575,.055,.0535}; // Array for interest rate of the Loan

//Varibles
double balance;  //Final balance of each month
double principal;	 // Principal of each month
 double monthlyInterestPaid; // Monthly Interest paid with each payment

//Table display
int row;
int maxRows = 12;  //maximum number of rows to display

//User entry input
int userEntry;
String userEntry2;
String userEntry3;

//Varibles for calculations per loan type
double mPayments30;
double mPayments15;
double mPayments07;


//calculating the arrays
mPayments30 = ((iRate[0]/12) * loanAmount) / (1-(Math.pow(1+(iRate[0]/12),
(- tMonths[0]))));
mPayments15 = ((iRate[1]/12) * loanAmount) / (1-(Math.pow(1+(iRate[1]/12), 
(- tMonths[1]))));
mPayments07 = ((iRate[2]/12) * loanAmount) / (1-(Math.pow(1+(iRate[2]/12), 
(- tMonths[2]))));


//initializing balance varible
balance = loanAmount;

//Calls in the console
Console c = System.console();

//Programming infromation
System.out.println();
	System.out.println("\t\t Mortgage Calculator");
	System.out.println("\t\t -------------------");
	System.out.println("\t\t Programmed by Mari Dutton");
	System.out.println("\t\t Mobile Loan Calculator   ");
	System.out.println("");


//User imput/instance Menu to determine type of loan
System.out.println("");
	System.out.println("");
	System.out.println("\t\t Select your Loan. ");
	System.out.println("\t\t ------------------");
	System.out.println("\t\t 1. 30 year with interest at 5.75%.");
	System.out.println("\t\t 2. 15 year with interest at 5.5%  ");
	System.out.println("\t\t 3. 07 year with interest at 5.35% ");
	System.out.println("\t\t 4. Exit");
	System.out.println("");

//Uner Entry Input from user
userEntry = (int)System.in.read();

	if (c == null)
	{
            System.err.println("Console Error.");
            System.exit(5);

        }

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\\

//=30 year loan
//If statement to enter User Entry input
if (userEntry == '1')
{

System.out.println("");
System.out.println("");
System.out.println("Loan Information:       ");
System.out.println("========================");
System.out.println("Loan Amount: $200,000.00");
System.out.println("Months: " + tMonths[0]);
System.out.println("Interest% Rate: " + iRate[0]);
System.out.printf ("Monthly payment amount will be $%.2f", mPayments30);
System.out.println("");
System.out.printl("++++++++++++++++++++++++++++++++++++++++++++++++++");
System.out.println("Payment  Amount Interest Paid   Principal Balance ");
System.out.println("++++++++++++++++++++++++++++++++++++++++");

for ( row =1; row <= tMonths[0]; row++)

//Calculating the Monthly Paid Interest;
monthlyInterestPaid = (iRate[0]/12) * balance;  //calculates monthly Interest Paid

//Calculating the Principal
principal = mPayments15 - monthlyInterestPaid;//calculates Principal


//Calculating the Balance
balance = balance - principal;


System.out.println("Payment "  +row+
":\t"+NumberFormat.getCurrencyInstance().format (mPayments30) +
",\t"+NumberFormat.getCurrencyInstance().format(monthlyInterestPaid) +
 ",\t"+NumberFormat.getCurrencyInstance().format(principal) +
",\t"+NumberFormat.getCurrencyInstance().format(balance));
if ((row % maxRows) == 0)
userEntry2 = c.readLine("Press Enter to continue... ");

		}
}

{

if (userEntry == '2')
	{
System.out.println("");
System.out.println("");
System.out.println("Loan Information:       ");
System.out.println("========================");
System.out.println("Loan Amount: $200,000.00");
System.out.println("Months: " + tMonths[1]);
System.out.println("Interest% Rate: " + iRate[1]);
System.out.printf ("Monthly payment amount will be $%.2f", mPayments15);
System.out.println("");
System.out.println("");
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++");
System.out.println("Payment Amount Interest Paid   Principal    Balance   ");
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++");

for ( row =1; row <= tMonths[1]; row++)
{

//Calculating the Monthly Paid Interest;
monthlyInterestPaid = (iRate[1]/12) * balance;  //calculates monthly Interest Paid

//Calculating the Principal
principal = mPayments15 - monthlyInterestPaid;//calculates Principal


//Calculating the Balance
balance = balance - principal;


System.out.println("Payment"  +row+
": \t"+NumberFormat.getCurrencyInstance().format (mPayments15) +
", \t"+NumberFormat.getCurrencyInstance().format(monthlyInterestPaid) +
", \t"+NumberFormat.getCurrencyInstance().format(principal) +
", \t"+NumberFormat.getCurrencyInstance().format(balance));

if ((row % maxRows) == 0)
userEntry2 = c.readLine("Press Enter to continue... ");

}
}
{

if (userEntry == '3')
	{
System.out.println("");
System.out.println("");
System.out.println("Loan Information:       ");
System.out.println("------------------------");
System.out.println("Loan Amount: $200,000.00");
System.out.println("Months: " + tMonths[2]);
System.out.println("Interest% Rate: " + iRate[2]);
System.out.printf("Monthly payment amount will be $%.2f", mPayments07);
System.out.println("");
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++");
System.out.println("Payment Amount Interest Paid   Principal Balance   ");
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++");

for ( row =1; row <= tMonths[2]; row++)
	{

//Calculating the Monthly Paid Interest;
monthlyInterestPaid = (iRate[2]/12) * balance;  //calculates monthly Interest Paid


//Calculating the Principal
principal = mPayments07 - monthlyInterestPaid;//calculates Principal


//Calculating the Balance
balance = balance - principal;


System.out.println("Payment " +row+
": \t"+NumberFormat.getCurrencyInstance().format (mPayments07) +
", \t"+NumberFormat.getCurrencyInstance().format(monthlyInterestPaid) +
", \t"+NumberFormat.getCurrencyInstance().format(principal) +
", \t"+NumberFormat.getCurrencyInstance().format(balance));

if ((row % maxRows) == 0)
userEntry2 = c.readLine("Thank you Please Press enter to exit ");
}
}

{
if(userEntry == '4')
{
System.out.println("\t Exiting the The Mortgage Calculator now. Thank you");
System.exit(0); //calling exit method
	}
}
}
}
}
}

Your program does NOT compile. I get 54 errors. Could you fix it?

Also please preserve the indentation when you post code. Unformatted code is very hard to read.

Your program does NOT compile. I get 54 errors. Could you fix it?

Also please preserve the indentation when you post code. Unformatted code is very hard to read.

Sorry about the first posting I am new at posting I usually just read and figure it out but I got stumped this time. I also noticed that my last 18 payments don't line up no idea what happened or how to fix it.

Thanks for taking the time to look at this. It isn't important but it feels unfinished without an exit command, and it is annoying to have to hit enter until the end if I want to exit or go to the orginal menu and pick a different loan.

The assignment is done as is but like I said it just doesn't feel finished.

Mari

/*---------------------------------------------------------------------------*/
//                            PROGRAM INFORMATION
//                        Programmer : Mari Dutton
//
//  Date    : (8/14/2010)
//  Name    : MortgageCalculator
//  Filename: MortgageCalculator.java
//	Purpose : The purpose of this program is to calculate mortgage payments.
//			  To calculate and display the customer's monthly mortgage
//            of $200000 at 5.75% interest over 30 years.The program will display
// 			  360 payments with interest by the Month for 30 years.

//---------------------------------------------------------------------------*/

        import java.text.DecimalFormat;     			//to import decimal format for money
	    import java.text.NumberFormat;	    			//to import number format
		import java.io.Console;        					//Calls the class Console for user input and output


    public class MortgageCalculator	    				// Starts the Class
   {
       public static void main(String[]args) throws Exception			//declaring main method with thrown Exception
      {

		//Arrays
		double   loanAmount = 200000;       		//Starting Balance of loan
		double[] tMonths = {360,180,84};	  		// Array for year term of the Loan
		double[] iRate   = {.0575,.055,.0535};  	// Array for interest rate of the Loan

	    //Varibles
 		double balance;                            //Final balance of each month
	    double principal;						   // Principal of each month
	    double monthlyInterestPaid;                // Monthly Interest paid with each payment

		//Table display
		int row;
		int maxRows = 12;  //maximum number of rows to display

        //User entry input
        int userEntry;
        String userEntry2;
        String userEntry3;

	    //Varibles for calculations per loan type

		double mPayments30;
		double mPayments15;
		double mPayments07;

		//calculating the arrays
		mPayments30 = ((iRate[0]/12) * loanAmount) / (1-(Math.pow(1+(iRate[0]/12), (- tMonths[0]))));
		mPayments15 = ((iRate[1]/12) * loanAmount) / (1-(Math.pow(1+(iRate[1]/12), (- tMonths[1]))));
		mPayments07 = ((iRate[2]/12) * loanAmount) / (1-(Math.pow(1+(iRate[2]/12), (- tMonths[2]))));


		//initializing balance varible
         balance = loanAmount;

		//Calls in the console
         Console c = System.console();

	//Programming infromation
	System.out.println();
		System.out.println("\t\t Mortgage Calculator");
		System.out.println("\t\t -------------------");
		System.out.println("\t\t Programmed by Mari Dutton");
		System.out.println("\t\t Mobile Loan Calculator   ");
		System.out.println("");


	//User imput/instance Menu to determine type of loan
	System.out.println("");
		System.out.println("");
		System.out.println("\t\t Select your Loan. ");
		System.out.println("\t\t ------------------");
		System.out.println("\t\t 1. 30 year with interest at 5.75%.");
		System.out.println("\t\t 2. 15 year with interest at 5.5%  ");
		System.out.println("\t\t 3. 07 year with interest at 5.35% ");
		System.out.println("\t\t 4. Exit");
		System.out.println("");

	//Uner Entry Input from user
	userEntry = (int)System.in.read();


	if (c == null)
	{
            System.err.println("Console Error.");
            System.exit(5);

        }

    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\\



	//=30 year loan
	//If statement to enter User Entry input
	if (userEntry == '1')
	{

		System.out.println("");
				System.out.println("");
				System.out.println("Loan Information:       ");
				System.out.println("========================");
				System.out.println("Loan Amount: $200,000.00");
				System.out.println("Months: " + tMonths[0]);
				System.out.println("Interest% Rate: " + iRate[0]);
				System.out.printf ("Monthly payment amount will be $%.2f", mPayments30);
				System.out.println("");
				System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
				System.out.println("Payment          Amount         Interest Paid   Principal        Balance   ");
				System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");

				for ( row =1; row <= tMonths[0]; row++)
				{

			//Calculating the Monthly Paid Interest;
			   	monthlyInterestPaid = (iRate[0]/12) * balance;  //calculates monthly Interest Paid


			//Calculating the Principal
			  	principal = mPayments30 - monthlyInterestPaid;	//calculates Principal


			//Calculating the Balance
				balance = balance - principal;


				System.out.println("Payment "  +row+
				  ":\t"+NumberFormat.getCurrencyInstance().format (mPayments30) +
		          ",\t"+NumberFormat.getCurrencyInstance().format(monthlyInterestPaid) +
		          ",\t"+NumberFormat.getCurrencyInstance().format(principal) +
		          ",\t"+NumberFormat.getCurrencyInstance().format(balance));

				if ((row % maxRows) == 0)
            		userEntry2 = c.readLine("Press Enter to continue... ");

				 //else if ((userEntry) ==4)
            		//userEntry3 = c.readLine("Press Enter to exit... ");


		}
}
{

	if (userEntry == '2')
	{

		System.out.println("");
				System.out.println("");
				System.out.println("Loan Information:       ");
				System.out.println("========================");
				System.out.println("Loan Amount: $200,000.00");
				System.out.println("Months: " + tMonths[1]);
				System.out.println("Interest% Rate: " + iRate[1]);
				System.out.printf ("Monthly payment amount will be $%.2f", mPayments15);
				System.out.println("");
				System.out.println("");
				System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
				System.out.println("Payment          Amount         Interest Paid   Principal        Balance   ");
				System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");

				for ( row =1; row <= tMonths[1]; row++)
				{

			//Calculating the Monthly Paid Interest;
			   	monthlyInterestPaid = (iRate[1]/12) * balance;  //calculates monthly Interest Paid


			//Calculating the Principal
			  	principal = mPayments15 - monthlyInterestPaid;	//calculates Principal


			//Calculating the Balance
				balance = balance - principal;


				System.out.println("Payment"  +row+
				  ": \t"+NumberFormat.getCurrencyInstance().format (mPayments15) +
		          ", \t"+NumberFormat.getCurrencyInstance().format(monthlyInterestPaid) +
		          ", \t"+NumberFormat.getCurrencyInstance().format(principal) +
		          ", \t"+NumberFormat.getCurrencyInstance().format(balance));

				if ((row % maxRows) == 0)
            		userEntry2 = c.readLine("Press Enter to continue... ");

		}
}
{

	if (userEntry == '3')
	{
		System.out.println("");
				System.out.println("");
				System.out.println("Loan Information:       ");
				System.out.println("------------------------");
				System.out.println("Loan Amount: $200,000.00");
				System.out.println("Months: " + tMonths[2]);
				System.out.println("Interest% Rate: " + iRate[2]);
				System.out.printf("Monthly payment amount will be $%.2f", mPayments07);
				System.out.println("");
				System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
				System.out.println("Payment          Amount         Interest Paid   Principal        Balance   ");
				System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");

				for ( row =1; row <= tMonths[2]; row++)
				{

			//Calculating the Monthly Paid Interest;
			   monthlyInterestPaid = (iRate[2]/12) * balance;  //calculates monthly Interest Paid


			//Calculating the Principal
			  	principal = mPayments07 - monthlyInterestPaid;	//calculates Principal


			//Calculating the Balance
				balance = balance - principal;


				System.out.println("Payment " +row+
				": \t"+NumberFormat.getCurrencyInstance().format (mPayments07) +
		        ", \t"+NumberFormat.getCurrencyInstance().format(monthlyInterestPaid) +
		        ", \t"+NumberFormat.getCurrencyInstance().format(principal) +
		        ", \t"+NumberFormat.getCurrencyInstance().format(balance));

				if ((row % maxRows) == 0)
            		userEntry2 = c.readLine("Press Enter to continue... ");

}
}

			{
			if(userEntry == '4')
				{
					System.out.println("Exiting the The Mortgage Calculator now. Thank you");
		System.exit(0); //calling exit method
	}
}
}
}
}
}

still looks like a mess to me It doesn't look that messed up on my end.

If it doesn't work let me know and I will change from Textpad to maybe Notepad++

You read in the user's input at the statement:
userEntry2 = c.readLine("Press Enter to continue...");

and ignore it. You could ask the user to exit loop by entering an X and then test the variable:
userEntry2 to see if its an X and exit the loop.

The code has several extra pairs of {}s???

You read in the user's input at the statement:
userEntry2 = c.readLine("Press Enter to continue...");

and ignore it. You could ask the user to exit loop by entering an X and then test the variable:
userEntry2 to see if its an X and exit the loop.

The code has several extra pairs of {}s???

I will try that thanks, and yeah I still have to clean the code up a bit before I turn the assignment in.

Thanks again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.