Hi,
I have just started learning c++,by my own,
I am stuck on this:
How to find overall best comptetitor's name and time.???
Please guide me.........
thanks in advance........
#include<iostream>
using std::cout;
using std::cin;
using std::endl;
using std::ios;
#include<string>
using std::string;
int main()
{
string name;
double time=0.0;
double time1=0.0;
double time2=0.0;
double totalTime=0.0;
int counter=0;
int count=0;
double besttime=0.0;
double temp=0.0;
while(name!="end"||"END")//not sure???//
{
cout<<"enter ur name"<<endl;
cin>>name;
if(name=="end"||name=="END")//if name entered is "end" stop the prog.//
{
break;
}
else
{
cout<<"enter the cycle time"<<endl;
cin>>time;
cout<<"enter the swim time"<<endl;
cin>>time1;
cout<<"enter the run time"<<endl;
cin>>time2;
if(time==0||time1==0||time2==0) //if any of the stage is not completed then total time should not be calculatd//
{
cout<<"total time:not completed"<<endl;
}
else
{
totalTime=time+time1+time2;
cout<<"total time is"<<totalTime<<endl;
if (totaltime>besttime)///Not working......???
{
besttime=totalTime;
}
if(time!=0&&time1!=0&&time2!=0)//if all stages r completed//
{
count++;
}
counter++;
}
}
}
cout<<"total no.of competitors"<<counter<<endl;
cout<<"no. of competitors who completed all stages"<<count<<endl;
cout<<"best overall competitor"<<endl;
cout<<"name"<<name<<endl;
cout<<"time:"<<besttime<<endl;
return 0;
}