When i try to rebuild this what i m geting

1>------ Rebuild All started: Project: depreciationarry, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'depreciationarry', configuration 'Debug|Win32'
1>Compiling...
1>arry.cpp
1>Compiling manifest to resources...
1>Linking...
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Users\agaba\Documents\Visual Studio 2005\Projects\depreciationarry\Debug\depreciationarry.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\agaba\Documents\Visual Studio 2005\Projects\depreciationarry\depreciationarry\Debug\BuildLog.htm"
1>depreciationarry - 2 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

This is the code help please

// Short-term parking at the airport, from 4am to midnight.

#include <iostream>
 using namespace std;
 // function

 void AskTimeIn(int *pHourIn,int *pMinIn);
 void AskTimeOut(int *pHourOut,int *pMinOut);
 void write(int hoursIn,int minsIn,int hoursOut,int minsOut);

int maint()
 {
  int hoursIn, minsIn,hoursOut, minsOut;

  // difine  fuction


  AskTimeIn(&hoursIn,&minsIn); //time in function.

  AskTimeOut(&hoursOut,&minsOut);//time out function.

  write(hoursIn,minsIn,hoursOut,minsOut);// write result function.

return 0;
 }

void AskTimeIn(int *pHourIn,int *pMinIn)
{
 char colon;
	cout <<"\n Enter Time  in ,H:M format: ";
	cin >>*pHourIn>>colon>>*pMinIn;
	cin.ignore();

}
void AskTimeOut(int *pHourOut,int *pMinOut)
{
 char colon;
 cout <<"\n Enter Time out ,H:M format: ";
 cin>>*pHourOut>>colon>>*pMinOut;
 cin.ignore();

}

 void write(int hoursIn,int minsIn,int hoursOut,int minsOut)
 {

  cout<<"\n Time in :"<<hoursIn<<":"<<minsIn;
  cout<<"\n Time out :"<<hoursOut<<":"<<minsOut;
 }

"int maint() {...}"

should be int main(){...}

Thanks every one...


But from the same code , I JUST ADD THIS FUNCTION TO CHECK VALID OF TIME BUT DONT WORK , WHERE DID I DONE WRONG

THIS IS NEW FUNCTION

validTime(hoursIn,minsIn,hoursOut,minsOut);// check  the time.


 bool validTime(int hoursIn,int minsIn,int hoursOut,int minsOut)
 {
 do
 {
  
   if(hoursIn<=24 && minsIn<=59 && hoursOut<=24 && minsOut<=59 && hoursIn<hoursOut && minsIn<minsOut)
    return true;
  
 }while(false);
 }

WHEN I APLY WRONG DATA , PROGRAM still working . INSTED OF FLAG ,

Help

validTime(hoursIn,minsIn,hoursOut,minsOut);// check the time.

should this be : float hoursIn, float minsIn, float hoursout, float minsOut) ?

validTime(hoursIn,minsIn,hoursOut,minsOut);// check the time.

should this be : float hoursIn, float minsIn, float hoursout, float minsOut) ?

i dont have to use data_type there i think

Your function does not need the do...while loop - nothing changes.
You should have a branching with both conditions handled, ie.

if ( time conditions are good )
   return true;
else
   return false;

Int for the data types is perfectly correct, assuming you're only dealing with whole hours and minutes.

The comparison of minutesIn to minutesOut could give bad results.
Consider in time of 12:42 and out time of 13:05 - minutesIn being greater than minutesOut is correct, but would not pass your test. For that matter, hoursIn and hoursOut could be equal in some cases, and only the minutes will determine the result. So, perhaps a bit more complex logic, like:

if (hours and minutes within bounds )
{
     if (hoursIn < hoursOut )
            return true;
     else if ( hoursIn == hoursOut )
     {
            if( minutesIn < minutesOut )  //assume no in/out same minute
                 return true;
      }
}
return false;

ok ,,now i m getting this error when i try to rebuild it

1>c:\users\agaba\documents\visual studio 2005\projects\car\car\school.cpp(96) : error C2447: '{' : missing function header (old-style formal list?)
1>Build log was saved at "file://c:\Users\agaba\Documents\Visual Studio 2005\Projects\car\car\Debug\BuildLog.htm"
1>car - 1 error(s), 0 warning(s)

i found to thread with the same try what they said , still getting same error

// Short-term parking at the airport, from 4am to midnight.

#include <iostream>
 using namespace std;
 // function

 void AskTimeIn(int *pHourIn,int *pMinIn);
 void AskTimeOut(int *pHourOut,int *pMinOut);
 bool validTime(int hoursIn,int minsIn,int hoursOut,int minsOut);
 float calcuLateFee(int hoursIn,int minsIn,int hoursOut,int minsOut,float *pFees,float *pTotalTime);
 void write(int hoursIn,int minsIn,int hoursOut,int minsOut);

int main()
 {
  int hoursIn, minsIn,hoursOut, minsOut;
  float fees,totalTime;


  // difine  fuction


  AskTimeIn(&hoursIn,&minsIn); //time in function.

  AskTimeOut(&hoursOut,&minsOut);//time out function.
  
 validTime(hoursIn,minsIn,hoursOut,minsOut);// check  the time.
calcuLateFee(hoursIn,minsIn,hoursOut,minsOut,&fees,&totalTime);// calculate late fees function.
  write(hoursIn,minsIn,hoursOut,minsOut);// write result function.

return 0;
 }

void AskTimeIn(int *pHourIn,int *pMinIn)
{
 char colon;
	cout <<"\n Enter Time  in ,H:M format(24hour clock): ";
	cin >>*pHourIn>>colon>>*pMinIn;
	cin.ignore();

}
void AskTimeOut(int *pHourOut,int *pMinOut)
{
 char colon;
 cout <<"\n Enter Time out ,H:M format(24hour clock): ";
 cin>>*pHourOut>>colon>>*pMinOut;
 cin.ignore();

}
 bool validTime(int hoursIn,int minsIn,int hoursOut,int minsOut)
 {
  do
  {
   if(hoursIn<=24 && minsIn<=59 && hoursOut<=24 && minsOut<=59)
    {
     if (hoursIn < hoursOut )
            return true;
     else if ( hoursIn == hoursOut )
     {
            if( minsIn < minsOut )  //assume no in/out same minute
                 return true;
      }
}
  }while(false);
 }

 float calcuLateFee(int hoursIn,int minsIn,int hoursOut,int minsOut,float *pFees,float *pTotalTime)
 {
 int totalHours;
 int totalMins;
 double  fees,totalTime;

 totalHours=hoursOut-hoursIn;  // calculate total hours car parked.

 totalMins=minsOut-minsIn;   // calculate total min car parked.
 
 totalTime = totalHours/60 + totalMins ; // calculate total time car pared in minutes.

 if(totalTime<=30)
 {
    fees=2.00;
 }
 else
 {
	 if(totalTime<=39)
	 {
	   fees=4.00;
	 }
	 else
	 {
	 fees = totalTime/30*2.00;
	 }
 }
 }

 void write(float totalTime,float fees);
 {
 cout<<"\n Total Time Car parked :"<<totalTime<<"minutes";
  cout<<"\n  :"<<fees<<"$";
 }
void write(float totalTime,float fees);
{
   .......
}

Delete the semicolon at the end of your last function's header line.

the function bool validTime (...) does not need the do...while(false) loop - that does nothing useful. If the good condition is not found inside the if block, thus returning true, simply return false as the last statement in the function.

This article has been dead for over six months. Start a new discussion instead.