Program Solar

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

#include<stdio.

h>
//to calculate net usage. Just to give an idea, Can be expanded easily.
float usage()
{
int tube,fan,bulb,plug;
float htube,hfan,hbulb,hplug;
float utube,ufan,ubulb,uplug, u;
printf("enter number of tubes");
scanf("%d",&tube);
printf("enter number hours the tubes are used");
scanf("%d",&htube);
printf("enter number of fans");
scanf("%d",&fan);
printf("enter number hours the fans are used");
scanf("%d",&hfan);
printf("enter number of bulbs");
scanf("%d",&bulb);
printf("enter number hours the bulbs are used");
scanf("%d",&hbulb);
printf("enter number of plugs");
scanf("%d",&plug);
printf("enter number hours the plugs are used");
scanf("%d",&hplug);
utube=20*tube*htube;
ufan=35*fan*hfan;
ubulb=15*bulb*hbulb;
uplug=30*plug*hplug;
u=(utube+ufan+ubulb+uplug)*30;
return u;
}
//To calculate the output from the solar unit
float usolar()
{
float s;
printf("enter average solar power generated per day (in watt).");
scanf("%f",&s);
return (s*30);
}
//TO switch the inverter between charging and discharging accordingly.
//not usable yet, can be added as a feature.
void switching()
{
int s,m,i;
printf("Enter parameters for solar and mains.");
scanf("%d",&s);
scanf("%d",&m);

if(s==-1)
{
if(m==0)
{
i=1;
}
if(m==1)
{
i=2;
}
}
if(s==1)
{
if(m==0)
{
i=1;
}
if(m==1)
{
i=2;
}
}
}
int main()
{
float u,us,tu,tp;
u=usage();
us=usolar();
tu=u-us;
if(tu>100)
{
tp=(6.5*100)+(tu-100)*7;
}
else if(tu<=100)
{
tp=tu*6.5;
}
else
{
printf("unexpected error");
}
printf("Total Usage = %f",u);
printf("Solar backup = %f",us);
printf("Net usage = %f",tu);
printf("Cost = %f",tp);
return 0;
}

You might also like