write a program that simulates the energy use of a house hold based on mainly the geyser's energy consumption. This is the first in a series of assignments improving on the model for this simulation. As a simple model the yearly consumption is based on a sinusoidal function approximating annual average daily ambient temperature. To run the model the program needs to first read the real-time-clock from the PC to establish the current day of the year. The time is then formatted and displayed on the screen together with a text based plot of the ambient temperature for the next year either as a histogram or a star plot.

#include <iostream>
#include <string>
#include <math.h>
#include <windows.h>
#include <conio.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>


using namespace std; 

/* set cursor macro */
#define setCursor(crd)  SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), crd )

/* settings */
#define SINEHEIGHT  20
#define monthstep  10
#define setCursor(crd)  SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), crd )
using namespace std;

void draw_graph(int months);
void pos1(int x,int y);
int main(int argc, char *argv[])
{
    int i=8,c=0,key;




draw_graph(720);

    for(int j=23;j>0;j--){
            pos1(0,(j));cout<<i;
             i+=1;
             pos1(5,25);cout<<"A";
             pos1(10,25);cout<<"S";
            pos1(15,25);cout<<"O";
            pos1(20,25);cout<<"N";
            pos1(25,25);cout<<"D";
            pos1(30,25);cout<<"J";
            pos1(35,25);cout<<"F";
            pos1(40,25);cout<<"M";
            pos1(45,25);cout<<"A";
            pos1(50,25);cout<<"MAY";
            pos1(58,25);cout<<"J";
            pos1(63,25);cout<<"JUL";
            pos1(68,25);cout<<"A";
            pos1(73,25);cout<<"S";
            pos1(78,25);cout<<"O";

            }
if (int x=getch()==27){
system("CLS");
pos1(7,10);cout <<"GOOD Bye!!!";
Sleep(3000);
cout << "it was good interacting with you";
Sleep(3000);
exit(0);}

    cin.get();
    return EXIT_SUCCESS;
}

void draw_graph(int months)
{
     COORD pos= {0,0};

     for (int x=0;x<months;x=x+monthstep){
         pos.X= ((x/monthstep)+2 );
         pos.Y = ( ( ( (  sin(x * 3.414 / 365+90) + 1) * ( SINEHEIGHT / 2 ) ) ) +2 );

         setCursor(pos);

         cout<<"**";
}
    pos.X = 0;
    pos.Y = SINEHEIGHT+1 ;
    setCursor(pos);
}

void pos1(int x,int y)
{
     COORD place;
     place.X=x;place.Y=y;
     setCursor(place);
}

This graph should be linked with computer date and time. When the date is changed using up-arrow of the key board, therefore the graph should shift as well. HELP

This article has been dead for over six months. Start a new discussion instead.