Click here to Skip to main content
15,911,327 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralGetting process address info in windows Pin
Zee man2-Mar-04 16:20
Zee man2-Mar-04 16:20 
QuestionHow do I find out when a byte is being sent or received by Dial-up networking? Pin
perrymail20002-Mar-04 14:56
perrymail20002-Mar-04 14:56 
QuestionIDL file? Pin
satcat2-Mar-04 13:34
satcat2-Mar-04 13:34 
AnswerRe: IDL file? Pin
Prakash Nadar2-Mar-04 14:04
Prakash Nadar2-Mar-04 14:04 
AnswerRe: IDL file? Pin
suneetchandok2-Mar-04 20:35
susssuneetchandok2-Mar-04 20:35 
GeneralHELP ME WITH *INI files Pin
Member 4689072-Mar-04 12:12
Member 4689072-Mar-04 12:12 
GeneralRe: HELP ME WITH *INI files Pin
Balkrishna Talele2-Mar-04 18:07
Balkrishna Talele2-Mar-04 18:07 
GeneralNEED HELP PLEASE!! Pin
Anonymous2-Mar-04 11:59
Anonymous2-Mar-04 11:59 
[code]
#include<iostream.h>
#include<math.h>
#include<iomanip.h>

class Watch
{
public:
Watch(int hour,int minute,int second);
Watch();
float get_min();
float get_hour();
float get_seconds();
void get_m_time();
void get_regular_time();

private:
int hrs;
int sec;
int min;

};

void Difference(Watch Watch_start, Watch Watch_end);

void main ()
{
Watch Watch_start, Watch_end;
int start_hour;
int start_minute;
int start_second;
char answer;
int end_hour;
int end_minute;
int end_second;

cout << "Welcome to my program\n";
cout << "This program will tell you the difference in times you enter\n";
cout << "It will also convert the time of day, to military time\n";
do
{
cout << "please enter the time of day you started\n";
cout << "please enter the hours first.\n";
cin >> start_hour;
cout << "now enter the minute you started.\n";
cin >> start_minute;
cout << "now please enter the seconds you started.\n";
cin >> start_second;


Watch_start = Watch(start_hour, start_minute, start_second);

Watch_start.get_regular_time();
Watch_start.get_m_time();

cout << "now please enter the time you ended\n";
cout << "again, please enter the hour first\n";
cin >> end_hour;
cout << "now enter the minute you ended\n";
cin >> end_minute;
cout << "now enter the second you ended\n";
cin >> end_second;

Watch_end = Watch(end_hour, end_minute, end_second);
Watch_end.get_regular_time();
Watch_end.get_m_time();


cout << "------------------------------------------------------------\n";
Difference(Watch_start, Watch_end);

cout << "Do you wish to enter another value?\n";
cin >> answer;

}

while ((answer == 'y') || (answer =='Y'));

};

Watch::Watch(int minute, int hour,int second)
{

hrs = hour;
min = minute;
sec = second;

};

Watch::Watch():hrs(0), min(0), sec(0)
{

};

float Watch::get_min()
{
return(min);
}

float Watch::get_hour()
{
return(hrs);
}

float Watch::get_seconds()
{
return(sec);
}

void Watch::get_m_time()
{

}
void Difference(Watch Watch_start, Watch Watch_end)
{

int diff_hour;
int diff_min;
int diff_sec;
int End_Hours = Watch_end.get_hour();
int End_Minutes = Watch_end.get_min();
int End_Seconds = Watch_end.get_seconds();
int Start_Hours;
int Start_Minutes;
int Start_Seconds;

if (Watch_end.get_hour() < Watch_start.get_hour())
{
End_Hours = Watch_end.get_hour() + 24;
diff_hour = End_Hours - Watch_start.get_hour();
}
else
{
diff_hour = Watch_end.get_hour() - Watch_start.get_hour();
}
if (Watch_end.get_min() < Watch_start.get_min())
{
End_Minutes = Watch_end.get_min() + 60;
diff_min = Watch_end.get_min() - Watch_start.get_min();
diff_hour = diff_hour - 1;
}
else
{
diff_min = Watch_end.get_min() - Watch_start.get_min();
}
if (Watch_end.get_seconds() < Watch_start.get_seconds())
{
End_Seconds = Watch_end.get_seconds() + 60;
diff_sec = Watch_end.get_seconds() - Watch_start.get_seconds();
diff_min = diff_min - 1;
}
else
{
diff_sec = Watch_end.get_seconds() - Watch_start.get_seconds();
}
cout <<setfill('0')<<setw(2)<<diff_hour <<"="" hours="" "<<endl;
="" cout="" <<setfill('0')<<setw(2)<<diff_min<<="" "="" minutes="" <<setfill('0')<<setw(2)<<diff_sec<<"="" seconds=""
}


void="" watch::get_regular_time()
{
="" float="" hour="hrs;
" if="" (hour=""> 12)
hour = hrs - 12;
}[/code]

im getting problems with the difference on minutes and seconds........it displays negative numbers.....any ideas?
GeneralRe: NEED HELP PLEASE!! Pin
Anonymous2-Mar-04 13:23
Anonymous2-Mar-04 13:23 
GeneralRe: NEED HELP PLEASE!! Pin
Steve S2-Mar-04 23:37
Steve S2-Mar-04 23:37 
GeneralRe: NEED HELP PLEASE!! Pin
DougW483-Mar-04 8:47
DougW483-Mar-04 8:47 
GeneralSimple Task Memory Watcher Pin
jcwallace032-Mar-04 11:55
jcwallace032-Mar-04 11:55 
GeneralRe: Simple Task Memory Watcher Pin
Balkrishna Talele2-Mar-04 18:04
Balkrishna Talele2-Mar-04 18:04 
GeneralRe: Simple Task Memory Watcher Pin
Dudi Avramov2-Mar-04 20:45
Dudi Avramov2-Mar-04 20:45 
GeneralRe: WaitForSingleObject Pin
mjmcinto2-Mar-04 10:59
mjmcinto2-Mar-04 10:59 
GeneralRe: WaitForSingleObject Pin
Diddy2-Mar-04 11:07
Diddy2-Mar-04 11:07 
Generaltext-to-phoneme conversion Pin
pxie2-Mar-04 9:50
pxie2-Mar-04 9:50 
GeneralRe: text-to-phoneme conversion Pin
Chiew Heng Wah2-Mar-04 17:38
Chiew Heng Wah2-Mar-04 17:38 
GeneralRe: text-to-phoneme conversion Pin
pxie3-Mar-04 3:34
pxie3-Mar-04 3:34 
GeneralHello all I want to capture an image from a Camera Pin
GegoTheWizard2-Mar-04 9:04
GegoTheWizard2-Mar-04 9:04 
GeneralRe: Hello all I want to capture an image from a Camera Pin
Chiew Heng Wah2-Mar-04 16:54
Chiew Heng Wah2-Mar-04 16:54 
GeneralRe: Hello all I want to capture an image from a Camera Pin
GegoTheWizard3-Mar-04 9:05
GegoTheWizard3-Mar-04 9:05 
GeneralRe: Hello all I want to capture an image from a Camera Pin
Chiew Heng Wah3-Mar-04 14:47
Chiew Heng Wah3-Mar-04 14:47 
GeneralRe: Hello all I want to capture an image from a Camera Pin
GegoTheWizard23-Mar-04 12:51
GegoTheWizard23-Mar-04 12:51 
GeneralMFC help!!! Pin
modeonetwo2-Mar-04 8:58
modeonetwo2-Mar-04 8:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.