I have an assignment to write an ATM program (it just needs to be basic) and I am getting one error when I try to compile:

On line 28, I get an expected unqualified-id before '{'.

I don't know that it's the only thing wrong with it, but any ideas would be great!

#include <iostream>
using namespace std;

int main()

{

        int pin, option, i;
        double balance = 1230.00;
        double withdraw, deposit;




   cout << "Please enter pin number: \n";
   cin >> pin;

        if (pin == 7230);

        { cout << "Pin Accepted \n";}

        else
       { cout << "Please try again. \n"; }


}
{

cout <<"**ATM**" endl;
 while(quit!)  {

cout << "Choose a transaction: \n";
cout << 1. "Withdraw Funds \n";
     << 2. "Deposit Funds \n";
     << 3. "Quit \n;"
     << "\n";
     << "Enter option: ";
cin >> option;

switch (option)
{
        case 1:
              cout << "Enter the amount you would like to withdraw: "
                        endl;
              cin >> withdraw;
              balance = balance - withdraw;

              cout << "You withdrew $ " << withdraw<< endl;
              cout << "Your remaining balance is $ " << balance <<endl;
         if
          { (withdraw < $500.00)
            {withdraw (amountRequested) ;
          }
         else
         { withdraw (0);
           notifyCustomer("The amount you entered has exceeded your"
            "daily withdrawl allowance. Please redo." );
         }
         case 2:
               cout << "Enter the amount you would like to deposit: "
                       endl;
               cin >> deposit;
               balance = balance + deposit;

               cout << "You deposited $ " << deposit << endl;
               cout << "Your new balance is $ " << balance << endl;

         case 3:
             quit = true;


break;




}

}
return 0;


}

point 1)next time before posting please preview your post to check whether you have code tags.
point 2)what the heck ?....this is probably the worst piece of code iv come across in years. I am thinking this is an assignment your teacher gave you to debug or something. But I will give you the benefit of doubt since you have at least some code. Your code had 1 too many syntactical mistakes. some of the things made no sense at all. If you are not the writer of the code I would advise you to go through the changes iv made. But anyway. I fixed it. Hope it helps.

#include <iostream>

using namespace std;

int main()

	{

		int pin, option, i;
		double balance = 1230.00;
		double withdraw, deposit;
		bool quit = false;




			cout << "Please enter pin number: \n";
			cin >> pin;

				if (pin == 7230)
				    {
					
				    	cout << "Pin Accepted \n";
				    }
				else
				    {
				    	cout << "Please try again. \n"; 
				        quit = true;
				    }


				

			
		      cout <<"**ATM**"<<endl;
		      while(quit != true)
			{
  			 cout << "Choose a transaction: \n";
			 cout << "1. Withdraw Funds \n";
			 cout << "2. Deposit Funds \n";
			 cout << "3. Quit \n;" << "\n";
			 cout << "Enter option: ";
			 cin >> option;

			 switch (option)
			   {
			     case 1:
			     cout << "Enter the amount you would like to withdraw: "<<endl;
			     cin >> withdraw;
			     balance = balance - withdraw;

			     cout << "You withdrew $ " << withdraw<< endl;
			     cout << "Your remaining balance is $ " << balance <<endl;
			    /*if(withdraw < 500)
				{						
				 withdraw (amountRequested) ; //this makes absolutely no sense at all...
				}*/
			       if(withdraw > 500)//now that makes more sense
				 {
				   withdraw  = 0;
				   cout<<"The amount you entered has exceeded your daily withdrawl allowance. Please redo." <<endl;
				 }
			      case 2:
			      cout << "Enter the amount you would like to deposit: "<<endl;
			      cin >> deposit;
			      balance = balance + deposit;
    			      cout << "You deposited $ " << deposit << endl;
			      cout << "Your new balance is $ " << balance << endl;

			      case 3:
			      quit = true;
  			      break;


			     }


						return 0;


		          }

	  }

Well, thanks for the help. Sorry I messed up the code brackets. I'm new here and I didn't know how to edit my post. (There's no option on the original post to do that.)

...I guess my code wasn't the neatest, but I am brand new at this. Thanks for the constructive criticism.

It works now.

point 2)what the heck ?....this is probably the worst piece of code iv come across in years.

If you are not the writer of the code I would advise you to go through the changes iv made. But anyway. I fixed it. Hope it helps.

UberJoker, don't be so judgmental. The original code definitely had some problems, but we've all seen much, much worse. And the code you posted still has lots of problems. It's "fixed" in that it now compiles and runs, but it's not "fixed" in any other sense.

  1. When the pin entered is incorrect, you display a message to try again, but give the user no chance to try again.
  2. When the user asks to withdraw money and enters $700, he is told he cannot withdraw that much money, yet $700 is withdrawn from the account anyway.
  3. Again, he's told to "redo", but is given no chance to redo anything.
  4. After the withdrawal is done, he immediately is asked how much he wants to deposit, even though he never said he was depositing anything. This is due to the lack of a "break" statement.
  5. You have a while (quit != true) loop that is not a loop. In no case will you ever go through this "loop" a second time, again due to the lack of a "break" statement.

If you're going to accuse someone of having the worst code you've seen in years, then claim to "fix" that person's code and then suggest that they study YOUR code, then at least make sure you post good code that someone new could use as an example of how to do it right. Your code is full of bugs.

Dude sorry to break your feelings...but i you don't seem to understand what's going on here. First of all I was getting the point across that his code actually is extremely crappy and in fact if you go to solve it you will realize that it is most likely a debugging activity given to him. second thing is that he did not mention anything about what he wants out of it. Hence you only assumed what he wants and are telling me crap about it. He only said "Error: expected unqualified-id token before " which, to a normal person would mean nothing more than fixing syntactical errors in the code and make it so that it would compile and run. First go look at his functions. the withdraw function he had didn't make any sense. at least i made it so that it makes sense and actually withdraws. I don't care what he wants to do with it afterwards and neither did he explain it so why are you assuming stuff?
I think he gets the point that he needs to put code tags in. It happened to me too when I first posted. I dont think he has a problem with it. I dont know why you do.

Dude sorry to break your feelings...but i you don't seem to understand what's going on here. First of all I was getting the point across that his code actually is extremely crappy and in fact if you go to solve it you will realize that it is most likely a debugging activity given to him. second thing is that he did not mention anything about what he wants out of it. Hence you only assumed what he wants and are telling me crap about it. He only said "Error: expected unqualified-id token before " which, to a normal person would mean nothing more than fixing syntactical errors in the code and make it so that it would compile and run. First go look at his functions. the withdraw function he had didn't make any sense. at least i made it so that it makes sense and actually withdraws. I don't care what he wants to do with it afterwards and neither did he explain it so why are you assuming stuff?
I think he gets the point that he needs to put code tags in. It happened to me too when I first posted. I dont think he has a problem with it. I dont know why you do.

I understand exactly what's going on here. I've been doing this for quite a while and I've dealt with lots of beginners and first-time posters. I'm not assuming I know what he wants. I have no idea what he wants. He marked it "solved", so he either fixed the program himself or thinks that your code fixed all of the problems. If he thinks it's the latter, he's mistaken. I'm pointing out that YOUR code doesn't do what it says and hence YOUR code doesn't make any sense either. Yes, he didn't explain what he wanted. He should have. I imagine you recognize the problems in your revised code and left them in there on purpose? That's fine, but you need to point that out. It should be obvious to anyone who actually runs it, but my experience has been that often newbies will take comments like "I fixed it" as "I fixed the whole program completely. This is how to do it. Study it as a model for how to do it right." Should they assume that? No. Do they assume that? Very often they do, so it's much better to phrase it as "I fixed this and this, but left the other problems in the code. You still have work to do."

As for you making the withdrawal part make sense, no, neither your withdrawal code nor his makes any sense at all. You don't subtract the number entered by the user from the balance, THEN check to make sure the user inputted a valid number. You check for valid input, then withdraw only if and when the input is valid.

I don't know what calling his code "extremely crappy" and "the worst code I've seen in years" accomplishes. He's a newbie by his own admission. He knows his code isn't very good yet. There are other ways to phrase it that gets the point across. This may be a debugging assignment or it may be his own code. We have no idea. We programmers tend to be a fairly blunt group, and that's a good thing in most ways, but even so, the language needs to be toned way down in response to a newbie making his very first post.

http://www.catb.org/~esr/faqs/smart-questions.html#id383614

I cant tell you how extremely stupid you sound. I don't even want to bother explaining anything to you any more. First you assume, then you build upon it(assumptions make a ass out of u and me ;).its cool though. No hard feelings. I will say no more. good luck with everything.

I cant tell you how extremely stupid you sound. I don't even want to bother explaining anything to you any more. First you assume, then you build upon it(assumptions make a ass out of u and me ;).its cool though. No hard feelings. I will say no more. good luck with everything.

I'm not the one assuming. You're assuming that it was a professor who gave the code as a debugging exercise and that anyone reading your post would know that "fixed" meant that "it now compiles and runs".

Anyway, you're right. There's no sense continuing this. The OP has marked this as solved, so there's probably no one else reading any of this. I've made my point. You've rejected it. What else is there to say?

i know i know :). No hard feelings brother.

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.