AIM:
To write a java
program for real-time program for implementing an alarm clock shall be
developed
ALGORITHM:
Step 1:
Start the program
Step 2:
Display init is used for initialization, and shall be
called from the main function of the program.
Step 3:
Before
the processes are created.
Step 4:
Display
time displays the current time, and shall be called by the clock process
Step 5:
Display
alarm time shows the current alarm time, and shall be called when a new alarm
time is set.
Step 6:
Erase
alarm time erases the displayed alarm time, and shall be called when the user
acknowledges an alarm
Step 7:
Display
alarm text is used to show an alarm activation, and shall be called when the
user shall be informed that the alarm has been activated
Step 8:
When the
alarm is activated the first time, and when the alarm is activated repeatedly
(which is every 10 seconds, according to the above stated requirements).
Step 9:
End of
programs
PROGRAM
#include<stdio.h>
#include<conio.h>
#include<dos.h>
struct clk
{
int hh,mm,ss;
}c1,c2;
void clock(int *h1,int *m1,int *s1)
{
*s1=*s1+1;
if(*s1==60)
{
*s1=0; *m1=*m1+1;
if(*m1==60)
{
*m1=0;*h1=*h1+1;
if(*h1==24)
*h1=0;
}
}
}
void timer(int *h,int *m,int *s)
{
if((*s)!=0)
{
*s=*s-1;
}
else if((*s)==0)
{
if(*m!=0)
{
*s=59;*m=*m-1;
}
else if(*m==0)
{
if(*h!=0)
{
*m=59;*h=*h-1;
}
}
}
}
void alarm()
{
int i;
while(!kbhit())
{
for(i=0;i<2;i++)
{
sound(5000);
delay(100);
nosound();
delay(200);
}
delay(500);
}
}