Help needed!!

This is a discussion on Help needed!! within the C++ Programming forums, part of the General Programming Boards category; HI I VE BEEN TRYING TO GET OUTPUT FOR THIS PROGRAM BUT ITS SHOWING SOME ERROR REGARDING HEADER FILES. I ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    6

    Help needed!!

    HI I VE BEEN TRYING TO GET OUTPUT FOR THIS PROGRAM BUT ITS SHOWING SOME ERROR REGARDING HEADER FILES.
    I JUS NEED UR GELP IN CORRECTING THE PROGRAM

    HERES THE SOURCE CODE ;-

    Code:
    //RENT A CAR PROJECT
    #include <iostream.h>
    #include<fstream.h>
    #include<stdio.h>
    #include<conio.h>
    #include<string.h>
    #include<iomanip.h>
    #include<dos.h>
    #include <stdlib.h>
    #include <limits.h>
    
    class Car
    {
    	private:
    		unsigned long s_no;
    		char strName[25];
    		int nDays;
    		char strType;
    		char strCompany[10] ;
    		int nAge;
    		char strDesig[10],strPIan;
    		int nCost; 
    		int ndln;
    		int nPhone;
    		char strWeekEnd;
    		char strSex;
    		int nBox;
    		int nPlan;
    
    	public:
    		unsigned long_get( );
    		void GetDetails( );
    		void Individual( );
    		void Status( );
    		void Company( ); 
    		void AddDetails( );
    		void ShowDetails( );
    		void ShowObject( );
    		void DeleteObject( );
    		void Modify( );
    	//	void Reports( );
    		void Search( );
    };
    Car cars;
    
    void Car::GetDetails( )
    {
    	char choice;
    	char use;
    
    
    		cout<<"Select Car Type\n";
    		cout<<"Economy .... .A\n";
    		cout<<"Luxury ......... B\n";
    		cout<<"4 x 4 .......... .C\n";
    		cout<<"Exit ............ ";
    		cin>>choice;
    
    		if((choice=='A')||(choice=='B')||(choice=='C'))
    		{
    			cout<<"please enter \n P for personal use or \n";
    			cout<<"C for company use";
    			cin>>use;
    			if(use=='P')
    				Individual();
    			else if (use=='C')
    			 Company();
    
    		}
    		else
    			cout<<"wrong option "; 
    }
    
    void Car::Individual()
    {
     
    	system ("CLS");
    	cout<<"enter the customer name\n";
    	cin>>strName;
    	cout<<"enter the age\n";
    	cin>>nAge;
    	cout<<"enter• the gender";
    	cin>>strSex;
    	cout<<"enter the driving license no\n";
    	cin>>ndln;
    	cout<<"enter the PO box\n";
    	cin>>nBox;
    	cout<<"enter the company\n";
    	cin>>strCompany;
    	cout<<"enter the destination\n";
    	cin>>strDesig;
    	cout<<"enter the phone no\n";
    	cin>>nPhone;
    	cout<<"you may proceed\n";
    	cout<<"1 ..... day plan\n";
    	 cout<<"2 ..... weekly plan\n";
    	 cout<<"3. .... monthly plan\n";
    	 cout<<"4 ..... yearly plan\n";
    
    cin>>nPlan;
    	switch(nPlan)
    	{
    		case 1:
    			 cout<<"is it a weekend(Y or N)\n";
    			 cin>>strWeekEnd;
    			  if(strWeekEnd='y')
    			  {
    				  int temp=50;
    				  cout<<"enter the no of days";
    				  cin>>nDays;
    				  nCost=(cars.nDays* 100)+temp;
    				cout<<nCost;
    			  }
    			 else
    			 { 
    				cout<<"enter the number of days";
    				cin>>nDays ; 
    				nCost=cars.nDays*100;
    				cout<<nCost;
    			 }
    			break;
    		  case 2:
    			  cout<<"enter the number of weeks";
    			  cin>>nDays;
    			  nCost=cars.nDays*90*7;
    			  cout<<nCost;
    			  break;
    		  case 3:
    			cout<<"enter the number of months";
    			cin>>nDays;
    			nCost=cars.nDays*65*30;
    			cout<<nCost;
    			break;
    
    		 case 4:
    			cout<<"enter the number of years";
    			cin>>nDays;
    			nCost=cars.nDays*35*365;
    			cout<<nCost;
    			break;
    
    		default:
    			cout<<"please check your option";
    	}
    }
    
    void Car::Company()
    {
    	int nRate=0;
    	char strdriver;
    	char company[10];
    		cout<<"company name";
    		cin>>company;
    		cout<<"do you need a driver";
    		cin>>strdriver;
    	if(strdriver=='y')
    	{
    		nRate=2000;
    	}
    	else
    	{
    		nRate=0;
    	}
    		char name[10];
    		int dln;
    		int box;
    		int plan;
    		int month,cost,year;
    		cout<<"enter the driver's name";
    		cin>>name;
    		cout<<"enter the driving license number";
    		cin>>dln;
    		cout<<"enter the PO box";
    		cin>>box;
    		cout<<"please enter the plan";
    		cout<<"l ..... monthly plan";
    		cout<<"2 ...., yearly plan";
    		cin>>plan;
    	switch(plan)
    	{
    		case 1:
    			cout<<"please enter the number of months";
    			cin>>month;
    			cost=(1200*month)+(nRate*month);
    			cout<<cost;
    		break;
    		case 2:
    			cout<<"please enter the number of years" ;
    			cin>>year;
    			cost=(9125*year)+(year*nRate*12);
    			cout<<cost;
    		break;
    
    	}
    	
    }
    
    void Car::Status()
    {
    	char choice=0;
    	int counter=0;
    
    	fstream infile;
    	infile.open("car",ios::in);
    	infile.seekg(0,ios::beg);
    	infile.read((char*)&cars,sizeof(cars));
    
    	while(!infile.eof( ))
    	{
    	if(cars.strType==choice)
    	counter=counter+1 ;
    	}
    	if (counter<5)
    	{
    		cout<<"cars are available";
    		cout<<"pIease continue";
    	}
    	else  
    	{
    		cout<<"no cars are available";
    		cout<<"enter another type of car";
    		Status ();
    	}
    }
    
    void Car::ShowDetails()
    {
    system ("CLS");
    	cout<<"customer name"<<strName;
    	cout<<"age"<<nAge;
    	cout<<"type"<<strType;;
    	cout<<"gender"<<strSex;;
    	cout<<"driving license number"<<ndln;;
    	cout<<"mobi1e"<<nPhone;
    	cout<<"p.o.box"<<nBox;;
    	cout<<"plan"<<strPIan;
    	cout<<"cost"<<nCost; 
    	cout<<"press any key to continue";
    	getch();
    }
    
    void Car::AddDetails()
    {
    fstream outfile;
    char choice='y';
    	while(choice=='y')
    	{
    	system ("CLS");
    		//char ch;
    		outfile.open("car",ios::app);
    		cars.GetDetails();
    		outfile.write((char*)&cars,sizeof(cars));
    		outfile.flush();
    		outfile.close();
    		cout<<"any more customers";
    		cin>>choice;
    	}
    }
    void Car::ShowObject()
    {  
    	fstream infile; 
    	infile.open("car",ios::in);
    	infile.seekg(0,ios::beg);
    	infile.read((char*)&cars,sizeof(cars));
    	while(!infile.eof())
    	{
    	cars.ShowDetails();
    	infile.read((char*)&cars,sizeof(cars));
    	}
    }
    
    void Car::DeleteObject()
    {
    	int code;
    	fstream infile,outfile;
    	cout<<"enter the dln to be deleted";
    	cin>>code;
    	outfile.open("tempfile",ios::app);
    	infile.open("car",ios::in);
    	infile.seekg(0,ios::beg);
    	infile.read((char*)&cars,sizeof(cars));
    	while(infile.eof())
    	{
    		if(cars.ndln!=code)
    		outfile.write((char*)&cars,sizeof(cars));
    		infile.read((char*)&cars,sizeof(cars));
    	}
    	infile.close();
    	outfile.close();
    	remove("car");
    	rename("temp","car");
    }
    /*void Car::Modify()
    {
    	fstream file;
    	int code;
    	int mod_choice,month;
      do 
    	{ 
    	//	clrscr();
    		cout<<"modify menu"<<'\n';
    		cout<<"change number of days\t1 "<<'\n';
    		cout<<"change contact person\t2"<<'\n';
    		cout<<"mobile number\t3"<<'\n';
    		cout<<"exit modify menu\t4"<<'\n';
    		 cout<<"PLEASE ENTER YOUR CHOICE\t\n";
    		cin>>mod_choice;
    if(mod_choice<4)
    {
    	cout<<"driving license number";
    	cin>>code;
    	file.open("car",ios::app);
    	file.seekg(0,ios::beg);
    	file.read((char*)&cars,sizeof(cars));
    	int n=file.tellg();
    	while(!file.eof());
    	{
    		if (code==cars.ndln)
    		{
    			switch(mod_choice)
    			{
    				case 1:
    				system ("CLS");
    					cout<<"enter the number of days";
    					cin>>month;
    					file.seekg(n-sizeof(cars));
    					file.write((char*)&cars,sizeof(cars));
    					file.flush();
    				break;
    				case 2:
    					system ("CLS"); 
    					cout<<"enter the contact person";
    					  gets(cars.strName);
    					  file.seekg(n-sizeof(cars));
    					//file.flush((char*)&cars,sizeof(cars));
    					file.flush();
    				break;
    				 case 3:
    					system ("CLS");
    					cout<<"enter the new phone number";
    					cin>>cars.nPhone;;
    					file.seekg(n-sizeof(cars));
    					file.write((char*)&cars,sizeof(cars));
    					file.flush();
    				break;
    				 default:
    				file.read((char*)&cars,sizeof(cars));
    				n=file.tellg();
    			}
    
    		file.close();
    		
    	}
     }while(mod_choice !=4);
    system ("CLS");
    	cout<<"you ended your modifying session";
    	cout<<"thank you";
    }*/
    void Car::Modify()
    {
    	fstream file;
    	int code;
    	int mod_choice,month;
        do 
    	{ 
    
    			//	clrscr();
    		cout<<"modify menu"<<'\n';
    		cout<<"change number of days\t1 "<<'\n';
    		cout<<"change contact person\t2"<<'\n';
    		cout<<"mobile number\t3"<<'\n';
    		cout<<"exit modify menu\t4"<<'\n';
    		 cout<<"PLEASE ENTER YOUR CHOICE\t\n";
    		cin>>mod_choice;
    		if(mod_choice<4)
    		{
    
    			cout<<"driving license number";
    			cin>>code;
    			file.open("car",ios::app);
    			file.seekg(0,ios::beg);
    			file.read((char*)&cars,sizeof(cars));
    			int n=file.tellg();
    			while(!file.eof());
    			{
    				if (code==cars.ndln)
    				{
    						switch(mod_choice)
    					{
    						case 1:
    						system ("CLS");
    							cout<<"enter the number of days";
    							cin>>month;
    							file.seekg(n-sizeof(cars));
    							file.write((char*)&cars,sizeof(cars));
    							file.flush();
    						break;
    						case 2:
    							system ("CLS"); 
    							cout<<"enter the contact person";
    							  gets(cars.strName);
    							  file.seekg(n-sizeof(cars));
    							//file.flush((char*)&cars,sizeof(cars));
    							file.flush();
    						break;
    						 case 3:
    							system ("CLS");
    							cout<<"enter the new phone number";
    							cin>>cars.nPhone;;
    							file.seekg(n-sizeof(cars));
    							file.write((char*)&cars,sizeof(cars));
    							file.flush();
    						break;
    						 default:
    						file.read((char*)&cars,sizeof(cars));
    						n=file.tellg();
    					}
    				}
    				
    			}
    				file.close();
    		} // end if
    	}while(mod_choice !=4); // end do
    	system ("CLS");
    	cout<<"you ended your modifying session";
    	cout<<"thank you";
    }
    
    
    
    
    void main()
    { 
    
    	int main_choice;
    	do
    	{
    		system ("CLS");
    		cout<<"main menu\n";
    		cout<<"new hire 1\n";
    		cout<<"modify  2\n";
    		cout<<"reports 3\n";
    		cout<<"delete 4 \n";
    		cout<<"show data 5\n";
    		cout<<"exit 6\n";
    		cout<<"enter your choice\n";
    		cin>>main_choice;
    			switch (main_choice)
    			{
    				case 1:
    				cars.AddDetails();
    				break;
    				case 2:
    					cars.Modify();
    				break;
    				case 3:
    					//	cars.reports();
    				break;
    				case 4:
    					cars.DeleteObject( );
    				break;
    				case 5:
    					cars.ShowObject();
    				break;
    				case 6:
    				 system ("CLS");
    					cout<<"you have ended this session\n";
    					cout<<"thank you\n";
    				break;
    			
    			}
    	}while(main_choice!= 5);
    
    }


    PLEASE HELP ME OUT!!

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,411
    1) Don't use caps.
    2) Why don't you give the errors?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    6
    sorry for the caps.....
    here are the errors....

    Compiler: Default compiler
    Executing g++.exe...
    g++.exe -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
    In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31,
    C:/Dev-Cpp/include/c++/3.4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
    C:\Users\malvika\Downloads\Documents\New Folder\main.cpp:432: error: `main' must return `int'

    Execution terminated

  4. #4
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    C:\Users\malvika\Downloads\Documents\New Folder\main.cpp:432: error: `main' must return `int'


    Code:
     
    int main(){};
    not
    Code:
     
    void main{};
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    And the bits that you do not understand of that is? To me, both errors are pretty much self-explanatory.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    this might have something to do with it:

    C:\Users\malvika\Downloads\Documents\New Folder\main.cpp:432: error: `main' must return `int'

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,310
    These lines include headers that are pre-standard:
    Code:
    #include <iostream.h>
    #include<fstream.h>
    #include<iomanip.h>
    They should be respectively replaced by:
    Code:
    #include <iostream>
    #include <fstream>
    #include <iomanip>
    These lines include headers that are non-standard:
    Code:
    #include<conio.h>
    #include<dos.h>
    Since you are not using any such non-standard functionality (at least from what I see) they should be removed.

    These lines include standard C headers:
    Code:
    #include<stdio.h>
    #include<string.h>
    #include <stdlib.h>
    #include <limits.h>
    It would be better to replace them with the corresponding C++ standard headers:
    Code:
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <climits>
    Incidentally, I noticed the use of gets(), which is unsafe. I would rather avoid mixing C-style and C++-style I/O.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Registered User
    Join Date
    Jan 2009
    Posts
    6
    thanx a lot abachler
    it was a stupid error bt nevertheless thnx a lot!!
    nw i get the output!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. free needed or not?
    By quantt in forum Linux Programming
    Replies: 3
    Last Post: 06-25-2009, 09:32 AM
  2. C Programmers needed for Direct Hire positions
    By canefan in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 09-24-2008, 11:55 AM
  3. lock needed in this scenario?
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-25-2008, 07:22 AM
  4. C++ help needed
    By Enkindu in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 08-31-2004, 11:24 PM
  5. semi-colon - where is it needed
    By kes103 in forum C++ Programming
    Replies: 8
    Last Post: 09-12-2003, 05:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21