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

7:10 AM ooo T-Mobile K C Programming Assignment 8 observe the usual guidelines r

ID: 3807073 • Letter: 7

Question

7:10 AM ooo T-Mobile K C Programming Assignment 8 observe the usual guidelines re garding the initial comment section, indenting, and so on. There must be a problem statement at the beginning of the program or a deduction will be made. .In if else statements, indent statements to be executed for if or else conditions three to five spaces. Align else or else if with corresponding if. -Indent statements within loops. The following data provided by the National Oceanic and Atmospheric Administration (taken from the Matlab text by Gilat) represent the maximum daily temperature in degrees Fahrenheit in Chicago and San Francisco during the month of August 2009. Table 1. Maximum Daily Temperatures in Chicago and San Francisco in August 2009 Date in Al Temperature San Francisco T 26 73 20 65 To Do Notifications Messages Courses Calendar

Explanation / Answer


// C code
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int main()
{
int day,C, SF;
FILE *outFile;
outFile = fopen("C:\output.txt","w");

// open input file
FILE *inFile;
if ((inFile = fopen("C:\input.txt","r")) == NULL)
{
printf("Error! opening file");
exit(1);
}
// open output file
if(outFile == NULL)
{
printf("Error!");   
exit(1);   
}


double averageC = 0, averageSF = 0;
int i = 0, SFgreaterC = 0;
int below80 = 0;
int lowC = 0, dayC = 1;
int highSF = 0, daySF = 1;

// read the day and temperatures
while (1)
{

fscanf((inFile, "%d%d%d",&day,&C,&SF) == 3)

// break if sentinal value is read from file
if(day == -999 || C == -999 || SF == -999)
break;

i++;
averageC = averageC + 1;
averageSF = averageSF + 1;
if(SF > C)
SFgreaterC++;

if(SF < 80 && C < 80)
below80++;

if(C < lowC)
{
lowC = C;
dayC = i;
}

if(SF > highSF)
{
highSF = SF;
daySF = i;
}

if (feof(fp))
printf(" End of file reached.");
}

// compute average
averageC = averageC/i;
averageSF = averageSF/i;

// output to file
fprintf(outFile,"Average temperature for month in Chicago: %0.2f ",averageC);
fprintf(outFile,"Average temperature for month in San Francisco: %0.2f ",averageSF);
fprintf(outFile,"Number of days the temperature was grater in San Francisco than CHicago: %d ",SFgreaterC);
fprintf(outFile,"Number of days when temperature was less that 80 in Sanfrancisco and CHicago: %d ",below80);
fprintf(outFile,"Lowest temperature in Chicago was on day: %d and the temperature was %d ",dayC, lowC);
fprintf(outFile,"Highst temperature in Sanfrancisco was on day: %d and the temperature was %d ",daySF, highSF);

// close files
fclose(inFile);
fclose(outFile);

return 0;
}

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