i'm having problems with this code. it's supposed to be a simple loan calculator i had to fix, but i can't get it to work. my freinds told me it wasn't possable to complete using 'catch', 'try' and 'throw' (not using throw), so i attempted to fix it with that.

here is the code:

#include <iostream>
#include <iomanip>

using namespace std;

void prog(int rtestart)
{
	double InterestRate, LoanInput, LoanTotal;
	int choice, creastart = 0;

	cout <<"\t\t\tSIMPLE LOAN CALCULATOR\n";

		do {
			try{
			system("cls");
			cout <<"To determine fixed interest on a loan, please answer the following and press ‘enter':\n";
			cout <<"How much do you want to borrow?\n";
			cin >> noboolalpha >> LoanInput;
			}
					catch(char)
		{

			cout << "exception occured. want to try again?" << endl;
			cout << system("pause") << " or press CTRL+C to quit!" << endl;

			creastart++;
			while(creastart = 1)
			{int restart(); creastart = 0;}
		}
				cout <<"What is the current interest rate from the lending institute?\n";
				cin >>InterestRate;
				cout <<"Your total repayment of principal + loan is:\n";
				LoanTotal=(LoanInput * InterestRate/100);
				cout <<fixed<<setprecision(2)<<"$"<<LoanTotal+LoanInput<<endl;
		
		system("pause");
		cout <<"Do you wish to use the program again? Y/N \n";
		cin >> choice;
		}
		while(choice=='Y' || choice=='y');
}

int main()
{
	int creastart = 1;

	while(creastart = 1)
	{int restart(); creastart = 0;}

i am only getting 1 error. which is the following:

g:\visual studio 2008\projects\test23a\test23a\test23a.cpp(49) : fatal error C1075: end of file found before the left brace '{' at 'g:\visual studio 2008\projects\test23a\test23a\test23a.cpp(44)' was matched

it is pointing to the following line: #include <iostream>

how do i fix this?

It is actually pointing to line 49. This is the default new-line at the end of your code. Look at the braces in your main. You have the opener for main, open and close for the while loop, BUT, you don't have the close brace for main.
Add another brace on line 49, without indentation.

thanks for the help. after changing that, the error dissapeared, but now when i run the program nothing happens at all, just a blank screen with a -

Edited 6 Years Ago by altXerror: n/a

Get rid of your current main function, and change line 6

void prog(int rtestart)

to

int main()

Please upvote my above post seeing as it helped you out. Thanks.

PS. Check that your braces all match up after the above!!!

This article has been dead for over six months. Start a new discussion instead.