Para el programa del ventilador, el equipo pensamos en aplicar el autoajuste del nivel de ventilacion dependiendo del valor de la temperatura, viento y humedad.
Modulo Temperatura
Se obtendra el grado de temperatura del ambiente. El rango de la temperatura es de 10 - 45 (Tiempo habitual en Monterrey)
int temp()
{
do
{
grado=(rand()%45)+1;
}
while(grado<=5);
printf("TEMPERATURA: %d ", grado);
return grado;
}
Modulo Viento
Se obtendra el valor de Km/Hr del viento.
int wind()
{
viento=(rand()%10);
printf("VIENTO: A %d KM/H ", viento);
return viento;
}
Modulo Humedad
Se obtendra el porcentaje de Humedad. EL rango es 40 - 100 de porcentaje de Humedad (Habitual en Monterrey)
int humo()
{
do {
humedad=(rand()%100)+1;
}while(humedad<=15);
printf("HUMEDAD: %d ", humedad);
return humedad;
}
Modulo Nivel
Indica el valor del nivel de ventilacion.
int niv()
{
temp();
wind();
humo();
if((grado>=35)&&(viento==0)&&(humedad<=30))
{
nivel=3;
}
if((grado>=30)&&(viento==0)&&(humedad<=40))
{
nivel=3;
}
if((grado>=25)&&(viento==1)&&(humedad<=40))
{
nivel=3;
}
if((grado>=20)&&(viento==1)&&(humedad<=55))
{
nivel=2;
}
if((grado>=15)&&(viento==2)&&(humedad<=60))
{
nivel=2;
}
if((grado>=25)&&(viento==2)&&(humedad<=70))
{
nivel=2;
}
if((grado>=35)&&(viento==3)&&(humedad<=85))
{
nivel=1;
}
if((grado>=25)&&(viento==3)&&(humedad<=95))
{
nivel=1;
}
if((grado>=15)&&(viento==4)&&(humedad<=60))
{
nivel=0;
}
if((grado>=5)&&(viento==4)&&(humedad<=70))
{
nivel=0;
}
if((grado>=30)&&(viento==4)&&(humedad<=85))
{
nivel=2;
}
if((grado>=45)&&(viento==5)&&(humedad<=95))
{
nivel=3;
}
return nivel;
}
Main
En el se imprime los valores y ademas de indicar el estado de ventilacion.
int main()
{
int n;
srand(time(NULL));
printf("\t\tVENTILADOR\n\n");
for (n=0;n<=1000;n++){
niv();
switch(nivel)
{
case 0:
printf("APAGADO\n");
break;
case 1:
printf("MODERADO\n");
break;
case 2:
printf("ALTO\n");
break;
case 3:
printf("MUY ALTO\n");
break;
default:
printf("ERROR\n");
}
sleep(2000);
}
system("pause");
return 0;
}
Codigo completo
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
int grado,viento,humedad,nivel;
float num;
int temp()
{
do
{
grado=(rand()%45)+1;
}
while(grado<=5);
printf("TEMPERATURA: %d ", grado);
return grado;
}
int wind()
{
viento=(rand()%10);
printf("VIENTO: A %d KM/H ", viento);
return viento;
}
int humo()
{
do {
humedad=(rand()%100)+1;
}while(humedad<=15);
printf("HUMEDAD: %d ", humedad);
return humedad;
}
int niv()
{
temp();
wind();
humo();
if((grado>=35)&&(viento==0)&&(humedad<=30))
{
nivel=3;
}
if((grado>=30)&&(viento==0)&&(humedad<=40))
{
nivel=3;
}
if((grado>=25)&&(viento==1)&&(humedad<=40))
{
nivel=3;
}
if((grado>=20)&&(viento==1)&&(humedad<=55))
{
nivel=2;
}
if((grado>=15)&&(viento==2)&&(humedad<=60))
{
nivel=2;
}
if((grado>=25)&&(viento==2)&&(humedad<=70))
{
nivel=2;
}
if((grado>=35)&&(viento==3)&&(humedad<=85))
{
nivel=1;
}
if((grado>=25)&&(viento==3)&&(humedad<=95))
{
nivel=1;
}
if((grado>=15)&&(viento==4)&&(humedad<=60))
{
nivel=0;
}
if((grado>=5)&&(viento==4)&&(humedad<=70))
{
nivel=0;
}
if((grado>=30)&&(viento==4)&&(humedad<=85))
{
nivel=2;
}
if((grado>=45)&&(viento==5)&&(humedad<=95))
{
nivel=3;
}
return nivel;
}
int main()
{
int n;
srand(time(NULL));
printf("\t\tVENTILADOR\n\n");
for (n=0;n<=1000;n++){
niv();
switch(nivel)
{
case 0:
printf("APAGADO\n");
break;
case 1:
printf("MODERADO\n");
break;
case 2:
printf("ALTO\n");
break;
case 3:
printf("MUY ALTO\n");
break;
default:
printf("ERROR\n");
}
sleep(2000);
}
system("pause");
return 0;
}
No hay comentarios:
Publicar un comentario
Les agradeceremos sus comentarios, sera de buena ayuda para nuestro trabajo.