|  | 
 | 
|  | ||
| 
 | 
| Subject:
basic C++ code Category: Computers > Programming Asked by: jm43-ga List Price: $5.00 | Posted:
21 Mar 2006 06:39 PST Expires: 20 Apr 2006 07:39 PDT Question ID: 710017 | 
| code a c++ program that inputs a series of 24 hourly temperatures from a file and outputs a bar chart (using stars) of the temeratures for the day.thetemperature should be printed to the left of the corisponding bar and there should be a heading that gives the scale of the chart. the range of the tempertures should be from -30 to 120. Because it is hard to display 150 characters on the screen you should have each star represent a range of three degrees. | 
|  | ||
| 
 | 
| There is no answer at this time. | 
|  | ||
| 
 | 
| Subject:
Re: basic C++ code From: rodneywa-ga on 21 Mar 2006 15:10 PST | 
| /*
--- Sample Input from myfile.txt ---
120
84
77
75
31
111
-10
-8
78
1
55
60
60
31
32
23
33
44
68
108
71
26
107
--- Sample Output ---
             -30**************************************************120
120.000000:     **************************************************
84.000000:      **************************************
77.000000:      ************************************
75.000000:      ***********************************
31.000000:      *********************
111.000000:     ***********************************************
-10.000000:     *******
-8.000000:      ********
78.000000:      ************************************
1.000000:       ***********
55.000000:      *****************************
60.000000:      ******************************
60.000000:      ******************************
31.000000:      *********************
32.000000:      *********************
23.000000:      ******************
33.000000:      *********************
44.000000:      *************************
68.000000:      *********************************
108.000000:     **********************************************
71.000000:      **********************************
26.000000:      *******************
107.000000:     **********************************************
--- c++ code ---
#include <stdio.h>
int main ()
{
        char str [150];
        float f,v;
        FILE * pFile;
        int i;
        pFile = fopen ("myfile.txt","r");
        printf("\t    
-30**************************************************120\n");
        while((fscanf(pFile, "%f", &f))!=EOF)
        {
                printf ("%f: \t",f);
                v=(f+30)/3;
                for(i=0;i<v;i++)
                        printf("*");
                printf("\n");
        }
        fclose (pFile);
        return 0;
} | 
| If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. | 
| Search Google Answers for | 
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |