Thursday, December 15, 2011

Debug this program for me. there is a error in line 418: do must have a while...?

include%26lt;iostream.h%26gt;


#include%26lt;conio.h%26gt;


#include%26lt;stdio.h%26gt;


#include%26lt;string.h%26gt;


#include%26lt;stdlib.h%26gt;


char password[30];


void horizon_prnlin();


struct date{


int dd,mm,yy;


};


void moneyin();


void moneyout();


void customercare();


void changebank();


void makeaccount();


struct bank{


int e_code;


char e_name[20];


struct date dob;


};


void main()


{


int ch;


char reply;


clrscr();


do


{


cout%26lt;%26lt;"\nEnter your choice";


cout%26lt;%26lt;"\n\nEnter 1 for help";


cout%26lt;%26lt;"\n\nEnter 2 for making the account";


cout%26lt;%26lt;"\n\nEnter 3 for depositing money";


cout%26lt;%26lt;"\n\nEnter 4 for withdrawing the money";


cout%26lt;%26lt;"\n\nEnter 5 for transfering the account to another bank";


cin%26gt;%26gt;ch;


switch(ch)


{


case 1:


customercare();


break;


case 2:


makeaccount();


break;


case 3:


moneyin();


break;


case 4:


moneyout();


break;


case 5:


changebank();


break;


default:


cout%26lt;%26lt;"Invalid choice";


break;


}


cout%26lt;%26lt;"\n\nDo you wish to continue (Enter y/Y to continue)";


cin%26gt;%26gt;reply;


}while(reply=='y'||reply=='Y');


getch();


}


void customercare()


{


char reply;


int ch;


do


{


cout%26lt;%26lt;"\n\n Enter your question";


cout%26lt;%26lt;"\n\n Enter 1 for knowing the fascilities provided by the bank";


cout%26lt;%26lt;"\n\n Enter 2 for loans and interest schemes";


cout%26lt;%26lt;"\n\n Enter 3 for queries about debit *** atm card";


cout%26lt;%26lt;"\n\n Enter 4 for the queries about retirement schemes of the company";


cout%26lt;%26lt;"\n\n Enter 5 for thr privacy conditions";


cout%26lt;%26lt;"\n\n Enter 6 for terimination conditions";


cout%26lt;%26lt;"\n\n Enter 7 for the publicity conditions";


cout%26lt;%26lt;"\n\n Enter 8 for the ammendments";


cin%26gt;%26gt;ch;


switch(ch)


{


case 1:


cout%26lt;%26lt;"\n\n The bank provides the following fascilities :-";


cout%26lt;%26lt;"\n1. It provides cover against any untoward event or accident.";


cout%26lt;%26lt;"\n2. Wealth managment options.";


cout%26lt;%26lt;"\n3. Core banking.";


cout%26lt;%26lt;"\n4. Loans for homes, education, healthcare etc.";


cout%26lt;%26lt;"\n5. Largest ATM network all over India";


cout%26lt;%26lt;"\n6. Free Debit *** ATM card";


cout%26lt;%26lt;"\n7. Instant credit upto Rs.50,000 of outstation cheques";


cout%26lt;%26lt;"\n\n************HAVE A NICE BANKING EXPERIENCE************";


cout%26lt;%26lt;"\n*****************************鈥?br>

cout%26lt;%26lt;"\nEnter your choice";


cout%26lt;%26lt;"\n\nEnter 1 for help";


cout%26lt;%26lt;"\n\nEnter 2 for making the account";


cout%26lt;%26lt;"\n\nEnter 3 for depositing money";


cout%26lt;%26lt;"\n\nEnter 4 for withdrawing the money";


cout%26lt;%26lt;"\n\nEnter 5 for transfering the account to another bank";


cin%26gt;%26gt;ch;


switch(ch)


{


case 1:


customercare();


break;


case 2:


makeaccount();


break;


case 3:


moneyin();


break;


case 4:


moneyout();


break;


case 5:


changebank();


break;


default:


cout%26lt;%26lt;"Invalid choice";


break;


}


break;


case 2:


cout%26lt;%26lt;"\n\n Preferential loans and present floating schemes are as follows";


cout%26lt;%26lt;"\n TYPE OF LOANS TIME PERIOD FLOATING RATES";


cout%26lt;%26lt;"\n Housing loans upto 5 years 3% of P.A ";


cout%26lt;%26lt;"\n 5-15 years 5% of P.A ";


cout%26lt;%26lt;"\n Automobile loans upto 3 years 5.5% of P.A";


cout%26lt;%26lt;"\n Personal loans upto 4 years 3.5% of P.A";


cout%26lt;%26lt;"\n Other loans upto 4 years 6.6% of P.A";


cout%26lt;%26lt;"\n\n************** HAVE A NICE BANKING EXPERIENCE **************";


cout%26lt;%26lt;"\n\nEnter your choice";


cout%26lt;%26lt;"\n\nEnter 1 for help";


cout%26lt;%26lt;"\n\nEnter 2 for making the account";


cout%26lt;%26lt;"\n\nEnter 3 for depositing money";


cout%26lt;%26lt;"\n\nEnter 4 for withdrawing the money";


cout%26lt;%26lt;"\n\nEnter 5 for transfering the account to another bank";


cin%26gt;%26gt;ch;


switch(ch)


{


case 1:


customercare();


break;


case 2:


makeaccount();


break;


case 3:


moneyin();


break;


case 4:


moneyout();


break;


case 5:


changebank();


break;


default:


cout%26lt;%26lt;"Invalid choice";


break;


}


break;


case 3:


cout%26lt;%26lt;"\n\nThe bank agrees to provide a free itnernational ATM-***-Debit card to all account holder";


cout%26lt;%26lt;"\n\t1.The card will be provided free of cost to acc. holders.";


cout%26lt;%26lt;"\n\t2.The debit card will be personalized.It will carry a photograph and signature of the holder";


cout%26lt;%26lt;"\n\t\tZERO LOST CARD LAIBILITY";


cout%26lt;%26lt;"\nThe holder will be protected against fraudulant use of lost/stolen/missing debit card";


cout%26lt;%26lt;"\nThe holder have to report the loss of debit card to bank @customer care(9898123456)";


cout%26lt;%26lt;"\nThe liability of card will be nill from then on.";


cout%26lt;%26lt;"\nRs.2000 will be deducted from holders account as damage repair fee.";


cout%26lt;%26lt;"********** HAVE A NICE BANKING EXPERIENCE **********";


cout%26lt;%26lt;"\nEnter your choice";


cout%26lt;%26lt;"\n\nEnter 1 for help";


cout%26lt;%26lt;"\n\nEnter 2 for making the account";


cout%26lt;%26lt;"\n\nEnter 3 for depositing money";


cout%26lt;%26lt;"\n\nEnter 4 for withdrawing the money";


cout%26lt;%26lt;"\n\nEnter 5 for transfering the account to another bank";


cin%26gt;%26gt;ch;


switch(ch)


{


case 1:


customercare();


break;


case 2:


makeaccount();


break;


case 3:


moneyin();


break;


case 4:


moneyout();


break;


case 5:


changebank();


break;


default:


cout%26lt;%26lt;"Invalid choice";


break;


}


break;


case 4:


cout%26lt;|||Line 418 is some way past the end of what Y!A will allow you to post. I suggest you post this question again with just the relevant bit copied into the question. Tell us the number of the first line you've copied, or highlight line 418 in some way.





Having said that, my guess is that the compiler means what it says. I don't know much about C++, and what I do know convinces me that I don't want to know any more, but the syntax for a do...while block is something like:





do


{


statement1;


statement2;


/* as many or as few statements as you need */


}


while (condition)





You may need a semicolon after the last ). The computer repeats the statements inside the { } until the condition becomes true. If you omit the "while (condition)" you get the error message that you're seeing. The other possibility is that you've missed out the }, or have something between } and "while" that's confusing the compiler. (Confusing a compiler isn't hard... most of them are written on the assumption that the programmer knows the syntax of the language, and they don't cope very well with missing or extra characters. If you omit a } somewhere in the middle of the program, the compiler can get all the way to the end before realising that you have more { than }. This is why, whenever I type a {, I put in the matching } before writing whatever goes between them, so that I don't forget afterwards.)





EDIT: I shouldn't post here before my second cup of coffee... do...while tells the the computer to repeat the statements *as long as* the condition is true, not until it becomes true. It differs from an ordinary while loop in that the computer will always execute the statements at least once, even if the condition is false when the loop starts, because the test is at the end of the loop, not the start. In an ordinary while loop, if the condition is false before the computer gets to the start of the loop, the statements inside the loop don't execute at all.|||Just a thought but I just ran into this problem tonight. I personally only had 27 lines of code on my page so I knew it was wrong. After a bit of research I found that the DivX add-on in IE was causing the error code. I disabled the add-on and the error went away. Something to try..

Report Abuse

No comments:

Post a Comment