could someone atleast point me in the right direction?
i'm new at this and
i've been working on this program and I just hit a brick wall. Its like my brain stopped working or something... :confused:
I have to make a "stop watch" program...have a class defined for stop_watch that stores the time in hours, minutes, and seconds. A constructor for defining the time, and one that will initialize the times to zero. Also, I need member functions to return the Hour, Minute, Second, display time as AM/PM, display time as military time. Another function for calculating the difference in time is needed also.
well this is kind of what i have so far... *although i believe it is completely wrong*
#include<iostream.h>
class StopWatch
{
public:
StopWatch (int hours, int minutes, int seconds);
StopWatch ();
int get_hour();
int get_minute();
int get_second();
int AM_PM();
int military();
void Time_difference(StopWatch Start_time, StopWatch End_time);
int hr, min, sec;
private:
int difference;
};
int main()
{
cout << "This is a Stop Watch Program.\n";
char chr;
do
{
StopWatch start, end;
cout << "Enter Start Time:\n"
<< "Hour: ";
cin >> start.hr;
cout << "Minute: ";
cin >> start.min;
cout << "Second: ";
cin >> start.sec;
cout << "Enter End Time:\n"
<< "Hour: ";
cin >> end.hr;
cout << "Minute: ";
cin >> end.min;
cout << "Second: ";
cin >> end.sec;
cout << "\nIn Military Time";
cout << "\n\tStart Time Entered: " << start.hr << ":"<< start.min << ":"<<start.sec<<"\n";
cout << "\tEnd Time Entered: " << end.hr << ":"<< end.min << ":"<<end.sec<<"\n";
cout << "Do another time calculation? Enter Y or N:";
cin >> chr;
}while((chr != 'N') && (chr != 'n'));
return 0;
}
StopWatch::StopWatch()
{
hr = 0;
min = 0;
sec = 0;
}
StopWatch::StopWatch(int hours, int minutes, int seconds)
{
hr = hours;
min = minutes;
sec = seconds;
}
int StopWatch::get_hour()
{
return hr;
}
int StopWatch::get_minute()
{
return min;
}
int StopWatch::get_second()
{
return sec;
}
int StopWatch::AM_PM()
{
}
int StopWatch::military()
{
}
void Time_difference(StopWatch Start_time, StopWatch End_time)
{
}