Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have alota of it written already. What I have so far is in the follwoing paste

ID: 3551660 • Letter: I

Question

I have alota of it written already. What I have so far is in the follwoing pastebucket link.


http://www.pastebucket.com/30259




For testing purposes, I am to make the datafile.txt contain the following integers:


55 62 68 74 59 45 41 58 60 67 65 78 82 88 91

92 90 93 87 80 78 79 72 68 61 59





I just need someone to help me finish the program, as I am stuck.





Write a computer program as a 32-bit console application in C to process a collection of daily high temperatures from an input file. Your program should count and print the number of hot days (high temperature 85 or higher), the number of pleasant days (high temperature between 60

Explanation / Answer


Dropbox-link:

https://dl.dropboxusercontent.com/u/78383401/chegg/temp.cpp


data-input file:

file-name is input.txt


55 62 68 74 59 45 41 58 60 67 65 78 82 88 91

92 90 93 87 80 78 79 72 68 61 59



Code:


#include <stdio.h>
#include <stdlib.h>
/*assess to exit fuction*/
/*Name:main*/

/* required function having a return type of void, with fourarguments:namely an input file pointer named filep, and threeoutput pointers;int*lowp, and int *mediump, and int*highp(in that order) */
void process_file(FILE* filep,int* lowp,int* mediump, int* highp){
   
    /*declare variables */
    int i;       /*counter for things scanned*/
    int low_temp;   /*low temperature*/
    int med_temp; /*medium temperature*/
    int high_temp; /*high temperature*/
    int temporary; /*this integer will get the item from the file and then assign*/
    int status; /*feedback scanned items*/
   
    /*initilize variables */
            i=0;
            low_temp=0;
            med_temp=0;
            high_temp=0;
            status = fscanf(filep,"%d",&temporary);
            while(status != EOF)
            {
                i=i+1;
                if (temporary < 60)
                    low_temp=low_temp+1;
                else if(temporary < 85 && temporary >= 60)
                    med_temp=med_temp+1;
                else if(temporary >= 85)
                    high_temp=high_temp+1;
                status=fscanf(filep,"%d",& temporary);
            }
            *lowp=low_temp;
            *mediump=med_temp;
            *highp=high_temp;
            fclose(filep);
}

int main(int argc, char*argv[])
{
    /*declare variables */
    FILE *inp;   /*input file pointer*/
      
    /*check the number of command line inputs */
    if(argc < 2)
    {
        printf("EE 233 spring 2014 p3 bhenson1, Ben Henson. ");
        exit(0);            
    }
    else if (argc >= 2)
    {
        /*attempt to open the file*/
        inp=fopen(argv[1],"r"); /*read_only is "r", write only is "w", */
        /*if file is not opened;error message;then close*/
        if(inp==NULL)
        {
            printf("Could not open input file ");
        }
        else
        {
            int lowp=0;
            int mediump=0;
            int highp=0;
           
            process_file(inp,&lowp,&mediump,&highp); //calling the process_file function
           
            int total=(lowp + mediump + highp); //total entries in the file
            printf("%s contain %d entries, and the table of results is ",argv[1],total);
            printf("low(<60)            medium(60-84)         high(>=85) ");
            printf("_____________________________________________________ ");
            printf("   %d              %d                %d ",lowp,mediump,highp);
        }
       
    }
    return(0);
}



Output:



Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote