DoG MikkyW
January 1st, 2009, 02:48 AM
This is just an alrm clock I wrote in C++...
#include <iostream>
#include <windows.h>
#include <conio.h>
using namespace std;
int main()
{
/*------------------------------------------------
-----------------Alarm Time Set-------------------
------------------------------------------------*/
int minute, hour;
cout<<"Please enter the hour which you wish"<<endl;
cout<<"to wake up at: "; cin>>hour;
cout<<"Please enter the minute that you wish"<<endl;
cout<<"to wake up at: "; cin>>minute;
cout<<"Thank You, carry on..."<<endl;
Sleep(3000);
/*------------------------------------------------
------------------End Alarm Set-------------------
------------------------------------------------*/
/*------------------------------------------------
-----------------Clock Time Set-------------------
------------------------------------------------*/
int seconds=0, minutes, hours;
cout<<"Welcome to the Alarm Clock Program"<<endl;
cout<<"\nWhat is the current hour: "; cin>>hours;
cout<<"What is the current minute: "; cin>>minutes;
/*------------------------------------------------
------------------End Clock Set-------------------
------------------------------------------------*/
/*------------------------------------------------
------This part deals with the clock counter------
------------------------------------------------*/
char beep, check;
beep=7;
for(seconds=0;seconds<=59;seconds--)
{
/*------------------------------------------------
----------Alarm Noise and Spacebar Reset----------
------------------------------------------------*/
while(hour==hours)
{
while(minute==minutes)
{
cout<<beep<<beep<<beep;
if(kbhit())
{
check=getch();
if(check==' ')
{
break;
}
else
{
cout<<"You have to press space!"<<endl;
}
}
break;
}
break;
}
/*------------------------------------------------
----------End of Alarm Noise Programming----------
------------------------------------------------*/
seconds++;
if(hours<=9){cout<<"0"<<hours<<":";}
else{cout<<hours<<":";}
if(minutes<=9){cout<<"0"<<minutes<<":";}
else{cout<<minutes<<":";}
if(seconds<=9){cout<<"0"<<seconds;}
else{cout<<seconds;}
Sleep(1000);
system("cls");
seconds++;
if(seconds==60)
{
seconds=0;
minutes++;
}
if(minutes==60)
{
minutes=0;
hours++;
}
if(hours==13)
{
hours=1;
}
if(kbhit())
{
char ch=getch();
if(ch==' '){break;}
}
}
/*------------------------------------------------
--------------End of clock counter----------------
------------------------------------------------*/
system("PAUSE");
return 0;
}
#include <iostream>
#include <windows.h>
#include <conio.h>
using namespace std;
int main()
{
/*------------------------------------------------
-----------------Alarm Time Set-------------------
------------------------------------------------*/
int minute, hour;
cout<<"Please enter the hour which you wish"<<endl;
cout<<"to wake up at: "; cin>>hour;
cout<<"Please enter the minute that you wish"<<endl;
cout<<"to wake up at: "; cin>>minute;
cout<<"Thank You, carry on..."<<endl;
Sleep(3000);
/*------------------------------------------------
------------------End Alarm Set-------------------
------------------------------------------------*/
/*------------------------------------------------
-----------------Clock Time Set-------------------
------------------------------------------------*/
int seconds=0, minutes, hours;
cout<<"Welcome to the Alarm Clock Program"<<endl;
cout<<"\nWhat is the current hour: "; cin>>hours;
cout<<"What is the current minute: "; cin>>minutes;
/*------------------------------------------------
------------------End Clock Set-------------------
------------------------------------------------*/
/*------------------------------------------------
------This part deals with the clock counter------
------------------------------------------------*/
char beep, check;
beep=7;
for(seconds=0;seconds<=59;seconds--)
{
/*------------------------------------------------
----------Alarm Noise and Spacebar Reset----------
------------------------------------------------*/
while(hour==hours)
{
while(minute==minutes)
{
cout<<beep<<beep<<beep;
if(kbhit())
{
check=getch();
if(check==' ')
{
break;
}
else
{
cout<<"You have to press space!"<<endl;
}
}
break;
}
break;
}
/*------------------------------------------------
----------End of Alarm Noise Programming----------
------------------------------------------------*/
seconds++;
if(hours<=9){cout<<"0"<<hours<<":";}
else{cout<<hours<<":";}
if(minutes<=9){cout<<"0"<<minutes<<":";}
else{cout<<minutes<<":";}
if(seconds<=9){cout<<"0"<<seconds;}
else{cout<<seconds;}
Sleep(1000);
system("cls");
seconds++;
if(seconds==60)
{
seconds=0;
minutes++;
}
if(minutes==60)
{
minutes=0;
hours++;
}
if(hours==13)
{
hours=1;
}
if(kbhit())
{
char ch=getch();
if(ch==' '){break;}
}
}
/*------------------------------------------------
--------------End of clock counter----------------
------------------------------------------------*/
system("PAUSE");
return 0;
}