3 Replies - 956 Views - Last Post: 20 February 2007 - 09:18 PM Rate Topic: -----

#1 bortiz0823  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 28-January 07

illegal ELSE without matching IF

Posted 20 February 2007 - 09:04 PM

Hi, I want to know why I have this error. I try all but my code still make the same errror with else without matching if. Somebody explain me???Thanks!
 
//Objective:  Make a class containing Customer information with credit limit

#include <iostream>
#include <conio.h>
#include <string.h>
using namespace std;

class Customer  //class declaration
{
private:
	char lastname[20]; 
	char name[10]; 
	double  id_num;
	float total;
	
public:
	void display();
	void disp();
	void purchase();
	static int Climit;
	float price;
};

  
int Customer::Climit = 5000; //static value

void Customer::display()
{

cout<<"Please, enter your NAME:";
cin>>name; 
cout<<"\nNow, enter your LAST NAME:";
cin>>lastname;


}
void Customer::disp()
{
cout<<"Enter your ID NUMBER of 6 digits:";
cin>>id_num;

while (id_num < 99999||id_num > 1000000)
{
cout<<"Please, enter a valid ID NUMBER:";
cin>>id_num;
}	
}

void Customer::purchase()
{
cout<<"\nPlease enter a total amount of your order "<<endl;
cin>>price;

	if (price<=Customer::Climit);
	{
	cout<< "\nYour transaction for "<<price<<" is accepted\n"<<endl;
	total=Customer::Climit-price;
	cout<< "\nYOUR BALANCE IS: "<<total<<endl;
	}
	else 
	{
		cout<< "Sorry but you cannot buy this item because your credit limit is: "<<Customer::Climit<<endl;
	}

}	
	

int main()

{
	
	Customer credit;
		credit.display();
		credit.disp();
		credit.purchase();
	
	
   
	
	cin.get();
	cin.get();

	return 0;

}


Is This A Good Question/Topic? 0
  • +

Replies To: illegal ELSE without matching IF

#2 keems21  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 185
  • Joined: 03-February 07

Re: illegal ELSE without matching IF

Posted 20 February 2007 - 09:06 PM

if (price<=Customer::Climit);



Get rid of this semicolon.
Was This Post Helpful? 0
  • +
  • -

#3 eXceed69  Icon User is offline

  • "Super Sentai Knight Of DawN"
  • member icon

Reputation: 7
  • View blog
  • Posts: 688
  • Joined: 12-November 06

Re: illegal ELSE without matching IF

Posted 20 February 2007 - 09:08 PM

you've terminated your if statement so that you had illegal else w/o matching IF error
if (price<=Customer::Climit);
Was This Post Helpful? 0
  • +
  • -

#4 bortiz0823  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 28-January 07

Re: illegal ELSE without matching IF

Posted 20 February 2007 - 09:18 PM

View Postkeems21, on 20 Feb, 2007 - 09:06 PM, said:

if (price<=Customer::Climit);



Get rid of this semicolon.

Thanks! Bro. LOL :D . Sorry
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1