I have an error in my code I couldnt find it

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

38 Replies - 1692 Views - Last Post: 13 April 2011 - 04:31 AM Rate Topic: -----

#1 Nana1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 39
  • Joined: 06-April 11

I have an error in my code I couldnt find it

Posted 06 April 2011 - 10:54 AM

Hi every one

I have an Assignment ,, its about making an ATM Machine by c++
but I have an error which I couldn't find until now
I'm using viual studio 2005


Iwish that u could help ,, I'm realy tiered

the Assignment algorithm in the attachment

and this is my code ::

#include<stdlib.h>
# include < iostream.h > 
int main ()

{
	int accountnumber=0,balance=0,pin=0,AmountOfDeposit=0,newBalance=0,amountOfAsdding=0,choice=0;
	cout<<" Welcome To the ATM Machine\n "<<endl;
	cout<<" please enter your account number and you pin\n";
		cin>>accountnumber;
		cin>>pin;
		if (accountnumber==1234,pin==54321)
		{
		cout<<"right account number and pin \n";
		cout<<"main menu/n";
		cout<<"1-view my balance./n";
		cout<<"2-Withdarw Cash/n";
		cout<<"3-Deposit fund/n";
		cout<<"4-Exit/n";
		}
		else
		{
			cout<<"False number,,Try Again\n";
			
			cin>>accountnumber;
			cin>>pin;}

	if (accountnumber==1234,pin==54321)
		{
		cout<<"right account number and pin \n";
		cout<<"main menu/n";
		cout<<"1-view my balance \n";
		cout<<"2-Withdarw Cash\n";
		cout<<"3-Deposit fund/\n";
		cout<<"4-Exit\n";}
		else
		{
			cout<<"False number,,Try Again\n";
			
			cin>>accountnumber;
			cin>>pin;}

	if (accountnumber==1234,pin==54321)
		{
		cout<<"right account number and pin /n";
		cout<<"main menu/n";
		cout<<"1-view my balance./n";
		cout<<"2-Withdarw Cash/n";
		cout<<"3-Deposit fund/n";
		cout<<"4-Exit/n";}
	else
		{
			cout<<"False number,,ur card has been taken";
			
	
	

		}
		
		do
		switch(accountnumber,pin)
		{
		case 1:
			cout<<"your balance is 5000 Dollars/n";
		system("cls");
		break;

		case 2:
			cout<<"enter the amount u want to cash/n";
			cin>>amountOfAsdding;
			cout<<endl;
			newBalance=balance+amountOfAsdding;
			cout<<newBalance<<endl;
	system("cls");
			break;

		case 3:
			cout<<"enter the The amount of deposit  into the machine/n";
			cin>>AmountOfDeposit;
			cout<<endl;
			newBalance=balance+AmountOfDeposit;
			cout<<newBalance;
			cout<<endl;
	system("cls");
			break;
		
		case 4:
			cout<<"Are u sure ..y/n>>??";
				cin>>choice;
			if(choice=='y')
			{
				break;
			}
			else
			{
				continue;
			}

		default:
			cout<<"choose a number from 1 to 4 /n";
		}
		cout<<"Do u want to do another operation  y/n  ..??";
		cin>>choice;
while(choice=='y'||'Y');


return 0;
		}


MOD EDIT: You found every stupid tag except the one you needed....the CODE tag! When you post code, USE CODE TAGS!!! It's written EVERYWHERE ON THE SITE!

Attached File(s)


This post has been edited by JackOfAllTrades: 06 April 2011 - 12:51 PM
Reason for edit:: Also removed Comic Sans font and annoying colors/sizes


Is This A Good Question/Topic? 0
  • +

Replies To: I have an error in my code I couldnt find it

#2 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 10:59 AM

What makes you format your post like that ?

Put your code in code tags.

Posted Image


Also mention the errors you are getting.
Was This Post Helpful? 0
  • +
  • -

#3 Nana1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 39
  • Joined: 06-April 11

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 11:11 AM

View Postchinchang, on 06 April 2011 - 10:59 AM, said:

What makes you format your post like that ?

Put your code in code tags.

Posted Image


Also mention the errors you are getting.



mm,,
I don't know how to edit it

This is it again

#include<stdlib.h>
# include < iostream.h > 
int main ()

{
	int accountnumber=0,balance=0,pin=0,AmountOfDeposit=0,newBalance=0,amountOfAsdding=0,choice=0;
	cout<<" Welcome To the ATM Machine\n "<<endl;
	cout<<" please enter your account number and you pin\n";
		cin>>accountnumber;
		cin>>pin;
		if (accountnumber==1234,pin==54321)
		{
		cout<<"right account number and pin \n";
		cout<<"main menu/n";
		cout<<"1-view my balance./n";
		cout<<"2-Withdarw Cash/n";
		cout<<"3-Deposit fund/n";
		cout<<"4-Exit/n";
		}
		else
		{
			cout<<"False number,,Try Again\n";
			
			cin>>accountnumber;
			cin>>pin;}

	if (accountnumber==1234,pin==54321)
		{
		cout<<"right account number and pin \n";
		cout<<"main menu/n";
		cout<<"1-view my balance \n";
		cout<<"2-Withdarw Cash\n";
		cout<<"3-Deposit fund/\n";
		cout<<"4-Exit\n";}
		else
		{
			cout<<"False number,,Try Again\n";
			
			cin>>accountnumber;
			cin>>pin;}

	if (accountnumber==1234,pin==54321)
		{
		cout<<"right account number and pin /n";
		cout<<"main menu/n";
		cout<<"1-view my balance./n";
		cout<<"2-Withdarw Cash/n";
		cout<<"3-Deposit fund/n";
		cout<<"4-Exit/n";}
	else
		{
			cout<<"False number,,ur card has been taken";
			
	
	

		}
		
		do
		switch(accountnumber,pin)
		{
		case 1:
			cout<<"your balance is 5000 Dollars/n";
		system("cls");
		break;

		case 2:
			cout<<"enter the amount u want to cash/n";
			cin>>amountOfAsdding;
			cout<<endl;
			newBalance=balance+amountOfAsdding;
			cout<<newBalance<<endl;
	system("cls");
			break;

		case 3:
			cout<<"enter the The amount of deposit  into the machine/n";
			cin>>AmountOfDeposit;
			cout<<endl;
			newBalance=balance+AmountOfDeposit;
			cout<<newBalance;
			cout<<endl;
	system("cls");
			break;
		
		case 4:
			cout<<"Are u sure ..y/n>>??";
				cin>>choice;
			if(choice=='y')
			{
				break;
			}
			else
			{
				continue;
			}

		default:
			cout<<"choose a number from 1 to 4 /n";
		}
		cout<<"Do u want to do another operation  y/n  ..??";
		cin>>choice;
while(choice=='y'||'Y');


return 0;
		}




the error is::

error C2061: syntax error : identifier 'cout'

This post has been edited by Nana1991: 06 April 2011 - 11:09 AM

Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg  Icon User is offline

  • member icon

Reputation: 3110
  • View blog
  • Posts: 9,479
  • Joined: 25-December 09

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 11:15 AM

The following line is incorrect:
#include <iostream.h> 

It should be:
#include <iostream> 


Also you will need to either use scope resolution operators std::cin or use using namespace std; since cin is in the std namespace.

Jim
Was This Post Helpful? 0
  • +
  • -

#5 Macjohn  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 80
  • View blog
  • Posts: 407
  • Joined: 10-April 09

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 11:17 AM

You better start by adding the code that jim gave you.
And appart from the cout you can try the printf statement.

This post has been edited by Macjohn: 06 April 2011 - 11:19 AM

Was This Post Helpful? 1
  • +
  • -

#6 Nana1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 39
  • Joined: 06-April 11

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 11:24 AM

View PostMacjohn, on 06 April 2011 - 11:17 AM, said:

You better start by adding the code that jim gave you.
And appart from the cout you can try the printf statement.



I did what jim told me to do it became ::
#include<stdlib.h>
# include < iostream >
using namespace std; 
int main ()


but the error still appearing ,,, and what do u mean by the print f statement ..??
Was This Post Helpful? 0
  • +
  • -

#7 Macjohn  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 80
  • View blog
  • Posts: 407
  • Joined: 10-April 09

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 11:27 AM

something like this;

printf("Your output comes in here");


Was This Post Helpful? 1
  • +
  • -

#8 chinchang  Icon User is offline

  • Indie Game Developer
  • member icon

Reputation: 192
  • View blog
  • Posts: 725
  • Joined: 22-December 08

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 11:28 AM

View PostNana1991, on 06 April 2011 - 11:54 PM, said:

View PostMacjohn, on 06 April 2011 - 11:17 AM, said:

You better start by adding the code that jim gave you.
And appart from the cout you can try the printf statement.



I did what jim told me to do it became ::
#include<stdlib.h>
# include < iostream >
using namespace std; 
int main ()


but the error still appearing ,,, and what do u mean by the print f statement ..??


Is the same error appearing ?
Was This Post Helpful? 0
  • +
  • -

#9 Nana1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 39
  • Joined: 06-April 11

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 11:41 AM

View PostMacjohn, on 06 April 2011 - 11:27 AM, said:

something like this;

printf("Your output comes in here");




it's somthing I didn't study ,,, and the assignment should only contain what I'v studied..

Thank u for ur helping :)

View Postchinchang, on 06 April 2011 - 11:28 AM, said:

View PostNana1991, on 06 April 2011 - 11:54 PM, said:

View PostMacjohn, on 06 April 2011 - 11:17 AM, said:

You better start by adding the code that jim gave you.
And appart from the cout you can try the printf statement.



I did what jim told me to do it became ::
#include<stdlib.h>
# include < iostream >
using namespace std; 
int main ()


but the error still appearing ,,, and what do u mean by the print f statement ..??


Is the same error appearing ?



yes it's the same one :(
Was This Post Helpful? 0
  • +
  • -

#10 Nana1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 39
  • Joined: 06-April 11

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 11:49 AM

please guys

I'm realy sick of it

I don't know what to do , It's so hard for me :'(
Was This Post Helpful? -1
  • +
  • -

#11 Macjohn  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 80
  • View blog
  • Posts: 407
  • Joined: 10-April 09

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 11:57 AM

send me the entire code...I will try to compile it in my pc.
Was This Post Helpful? 1
  • +
  • -

#12 jimblumberg  Icon User is offline

  • member icon

Reputation: 3110
  • View blog
  • Posts: 9,479
  • Joined: 25-December 09

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 11:57 AM

Post your current code along with the complete error message exactly as it appears in your development system.


Jim
Was This Post Helpful? 0
  • +
  • -

#13 Nana1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 39
  • Joined: 06-April 11

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 12:01 PM

View PostMacjohn, on 06 April 2011 - 11:57 AM, said:

send me the entire code...I will try to compile it in my pc.


okay

I uploaded to 4shared;;
My link


thanx for ur helping I'm realy tired
Was This Post Helpful? 0
  • +
  • -

#14 Macjohn  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 80
  • View blog
  • Posts: 407
  • Joined: 10-April 09

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 12:04 PM

sorry bro...I will help you put you'll have to post it here.
do forget the [code] statements

This post has been edited by Macjohn: 06 April 2011 - 12:06 PM

Was This Post Helpful? 1
  • +
  • -

#15 jimblumberg  Icon User is offline

  • member icon

Reputation: 3110
  • View blog
  • Posts: 9,479
  • Joined: 25-December 09

Re: I have an error in my code I couldnt find it

Posted 06 April 2011 - 12:08 PM

In this line you have a space between the # and include# include < iostream > The preprocesser can not handle the space this line should be: #include <iostream> .


Jim
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3