Site hosted by Angelfire.com: Build your free website today!

Program 37

C++

K. Dzwonkiewicz

 

You have a table of temperatures for a one-week period for some cities from around the world.  This information is in a file called temper37,dat

            \\common\\dzwon\\temper37.dat

 

Your program retrieve the data and produce a chart based on a MENU selection...here is the MENU:

 

MENU for TEMPERATURES

1)      City names only

2)      City with average temperatures

3)      Ranking (with city name) of average temperatures (Hi-Low)

4)      Print all cities with all daily temperatures

5)      Find highest dailyy temp. with city name

6)      Quit

 

Hints:  Have 7 functions

1)Load file        2)Menu      3)City       4)CityAve     5)Rank      6)All    7)High

 

If you sort some of the data but not all of it re-load file so data is back to correct order.

 

Have your ifstream be LOCAL.  Therefore you must pass the stream as a reference parameter...

 

Partial form...

            Proto-type>>>  void LoadFile(ifstream & and the arrays);

            Passing>>>       LoadFile(konrad, citi, avtemp, alltemp);

            Receiving          LoadFile(ifsteam& konrad and the arrays);

 

SAMPLE OUTPUT:

 

MENU for TEMPERATURES

1)      City names only

2)      City with average temperatures

3)   Ranking (with city name) of average temperatures (Hi-Low)

4)      Print all cities with all daily temperatures

5)      Find highest dailyy temp. with city name

6)      Quit

               ENTER CHOICE:_1

 

CITY LIST                                                      If Miss Grasshopper had found a spider

1)      CAIRO                                                      instead of a moth in the computer, would

2)      KATHMANDU                                         we say ‘de-arachnid’?

3)      CASABLANCA

4)      SANAA

 

ENTER CHOICE:_4

CITY LIST ALL TEMPERATURES

            NAME                         S          M         T          W        R          F          S

1)  CAIRO                               98        99        97        96        88        89        90

2)  KATHMANDU                 81        85        84        81        80        83        82

3)  CASABLANCA                99        98        96        95        97        92        93

4)  SANNA                             67        77        65        64        68        69        70

 

ENTER CHOICE:_6

 

How the file looks on the disk (average is not stored)

CAIRO

98 99 97 96 88 89 90

KATHMANDU

81 85 84 81 80 83 82

CASABLANCA

99 98 96 95 97 92 93

SANNA


67 77 65 64 68 69 70

ÓEmerald Star 2002