OOMPL :Weather report

//============================================================================
// Name        : weather_rep.cpp
// Author      : Parashar
// Version     :
// Copyright   : Do not try this at home :p
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

class weather
{
public:
    int day,h_temp,l_temp;
public:
    weather();
    void input(int);
    void output();
    //void average();
};

weather::weather()
{
    day=99;
    h_temp=999;
    l_temp=-999;
}

void weather::input(int counter)
{
    cout<<"enter high temperature"<<endl;
    cin>>h_temp;
    cout<<"enter low temperature"<<endl;
    cin>>l_temp;
    day=counter+1;

}

void weather::output()
{
    cout<<"_________________________________"<<endl;
    cout<<"|\t"<<day<<"|\t"<<h_temp<<"\t|"<<l_temp<<"\t|"<<endl;

}



int main()
{
    cout << "!!!Made by PARASHAR!!!" << endl; // prints !!!Made by PARASHAR!!!

    float avg_ht,avg_lt,high_sum=0,low_sum=0;
    char ans;
    int counter=0,day=0;

    weather w[30];
    do
    {
        int choice;
        day=counter+1;
        cout<<"MENU"<<endl;
        cout<<"1)INPUT"<<endl;
        cout<<"2)OUTPUT"<<endl;
        cout<<"enter your choice"<<endl;
        cin>>choice;
        if(counter<=30)
                        {
        switch(choice)
        {
        case 1:
            cout<<"please enter data for day "<<day<<endl;
            w[counter].input(counter);
            counter++;
            break;

        case 2:
        cout<<"the entered values are"<<endl;
        cout<<"|   day\t  |   High temp\t| Low temp|"<<endl;
        for(int i=0;i<counter;i++)
            {
            w[i].output();
            }
            for(int i=0;i<counter;i++)
                        {

                            high_sum=high_sum+w[i].h_temp;
                        }
                        avg_ht=high_sum/counter;
                        cout<<endl<<"average high temp:- "<<avg_ht<<endl;;

                    for(int i=0;i<counter;i++)
                        {

                            low_sum=low_sum+w[i].l_temp;


                        }
                        avg_lt=low_sum/counter;
                        cout<<endl<<"average low temp:- "<<avg_lt<<endl;;

                        high_sum=low_sum=avg_ht=avg_lt=0;
            break;
        }
        //average
                        }
                                                else
                                                {
                                                    cout<<"you have already entered data for 30 days /n"<<endl<<" now exiting program....";
                                                    ans='n';
                                                }


                cout<<"do u wanna continue? \n if yes please press y";
                        cin>>ans;



    }while(ans=='y' || ans=='Y');
    return 0;
}



/*==============================================================================================================================
 *             OUTPUT
 ===============================================================================================================================*
 *
 *!!!Made by PARASHAR!!!
MENU
1)INPUT
2)OUTPUT
enter your choice
1
please enter data for day 1
enter high temperature
20
enter low temperature
10
do u wanna continue?
 if yes please press yy
MENU
1)INPUT
2)OUTPUT
enter your choice
1
please enter data for day 2
enter high temperature
40
enter low temperature
20
do u wanna continue?
 if yes please press yy
MENU
1)INPUT
2)OUTPUT
enter your choice
2
the entered values are
|   day      |   High temp    | Low temp|
_________________________________
|    1|    20    |10    |
_________________________________
|    2|    40    |20    |

average high temp:- 30

average low temp:- 15
do u wanna continue?
 if yes please press yy
MENU
1)INPUT
2)OUTPUT
enter your choice
1
please enter data for day 3
enter high temperature
10
enter low temperature
0
do u wanna continue?
 if yes please press yy
MENU
1)INPUT
2)OUTPUT
enter your choice
2
the entered values are
|   day      |   High temp    | Low temp|
_________________________________
|    1|    20    |10    |
_________________________________
|    2|    40    |20    |
_________________________________
|    3|    10    |0    |

average high temp:- 23.3333

average low temp:- 10
do u wanna continue?
 if yes please press y
 */

Comments

Popular posts from this blog

NASM: program to find largest number from an array of 32-bit numbers(hard-coded)

Rules for drawing a FLOWCHART

GENERAL: Top 10 Mst FAMOUS hackers