Question

Assume that, for a given town, mid-day daily temperature in Fahrenheit was measured for a month and stored in a file called t

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the answer for you, a like would be helpful..

C Code:

#include <stdio.h>

void main()
{
    FILE *input, *output;
    double f, cel, small = 0, large = 0, avg = 0, sum = 0;
    int count = 0, flag = 0;
    input = fopen("temperature.txt", "r");
    output = fopen("results.txt", "wb");
    if (input == NULL)
    {
        printf("Can't open the input.");
    }
    else
    {
        do
        {
            count++;
            fscanf(input, "%lf", &f);
            cel = ((f - 32) * 5 / 9);
            if (flag == 0)
            {
                large = cel;
                small = cel;
                flag++;
            }
            else
            {
                if (cel < small)
                    small = cel;
                if (cel > large)
                    large = cel;
            }
            sum = sum + cel;
            avg = sum / count;
            fprintf(output, "%lf\n", cel);
        } while (!feof(input));
    }
    fprintf(output, "Small: %lf\n", small);
    fprintf(output, "Large: %lf\n", large);
    fprintf(output, "Average: %lf\n", avg);
}

1 3 e a go o { EE { } 년 نہا C temperatureFTOC.C X C temperatureFTOC.C > main #include <stdio.h> 2 void main() 4 5 FILE *input

temperature.txt:

C temperatureFTOC.C temperature.txt X temperature.txt 1 1000 2 800 3 400 E. ⓇOAO Ln 3, Col4 Spaces: 4 UTF-8 CRLF Plain Text

results.txt:

Add a comment
Know the answer?
Add Answer to:
Assume that, for a given town, mid-day daily temperature in Fahrenheit was measured for a month...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assume that, for a given town, mid-day daily temperature in Fahrenheit was measured for a month...

    Assume that, for a given town, mid-day daily temperature in Fahrenheit was measured for a month and stored in a file called temperature.txt. Write a complete C language program that reads the stored temperatures, one at a time, from the file temperature.txt and converts the read temperature to its equivalent in Celsius. Your program should store each converted temperature in an output file called results.txt. Your program should also find the average, the minimum, and the maximum temperatures in Celsius...

  • Write a program that would ask the user to enter an input file name, and an...

    Write a program that would ask the user to enter an input file name, and an output file name. Then the program reads the content of the input file, and read the data in each line as a number (double). These numbers represent the temperatures degrees in Fahrenheit for each day. The program should convert the temperature degrees to Celsius and then writes the numbers to the output file, with the number of day added to the beginning of the...

  • Write a program named FahrenheitToCelsius that accepts a temperature in Fahrenheit from a user and converts...

    Write a program named FahrenheitToCelsius that accepts a temperature in Fahrenheit from a user and converts it to Celsius by subtracting 32 from the Fahrenheit value and multiplying the result by 5/9. Display both values to one decimal place. For example, if 88.5 degrees is input, the output would be: 88.5 F is 31.4 C Answer in C# (Posting incomplete code i have so far that wont run correctly.) using System; using static System.Console; class FahrenheitToCelsius { static void Main()...

  • Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin...

    Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin Newton Your program should take a character which represents the temperature to convert from and a value to be converted to using the following specification: C - Celsius K - Kelvin N - Newton In addition your program should take in the following character to exit the program: X - eXit the program The numeric input for your program should be of type double....

  • java ASAP Assume that you have tracked daily minutes of you work out for a week....

    java ASAP Assume that you have tracked daily minutes of you work out for a week. Save the following data into a text file in a notepad. 50 10 36 11 47 30 Write a java program that reads the minutes for a week from the text file that you created. Read the minutes from the input file into the array in one execution of the program.write a java method to find out the maximum and minimum values. Your program...

  • General overview This program will convert a set of temperatures from Fahrenheit to Celsius and Kelvin....

    General overview This program will convert a set of temperatures from Fahrenheit to Celsius and Kelvin. Your program will be reading in three double values. The first values are starting and ending temperatures. The third value is the increment value. There is no prompt for the input. There is an error message that can be displayed. This is discussed later. You need to display output for all of the values between the starting and ending values. First two values are...

  • Purpose of the assignment To apply simple JavaScript concepts to create a Fahrenheit to Celsius (and...

    Purpose of the assignment To apply simple JavaScript concepts to create a Fahrenheit to Celsius (and Celsius to Fahrenheit) conversion program. I need both please! What’s required of you. Having looked at some basic examples of JavaScript on http://www.w3schools.com and at the “simple math with forms/inputs and validation” example in detail , I would like you to now apply those concepts to create a simple page that lets users type in some temperature value in the Fahrenheit/Celsius scale and when...

  • (By using HCS12 assembly)You have a table of 10 Fahrenheit temperatures stored as words in Flash....

    (By using HCS12 assembly)You have a table of 10 Fahrenheit temperatures stored as words in Flash. Use the posted lab1_b.asm file as starting point. Write an assembly program that converts every Fahrenheit temperature element in Fahrs array into a Celsius temperature and stores the result at the corresponding element in Cels array. Use this relation: C = (5/ 9) * (F 32) for conversion. Because temperatures are signed, you will have to use signed multiplication and division instructions in your...

  • Write a program in C++ that gives the temperature of earth at a depth. It must...

    Write a program in C++ that gives the temperature of earth at a depth. It must be in C++ and follow the information below: Problem description Write a program to take a depth in kilometers inside the earth as input data; calculate and display the temperature at this depth in both degrees Celsius and degree Fahrenheit. The formulas are: Celsius temperature at depth in km: celsius = 10 x depth(km) + 20 Convert celsius to fahrenheit: fahrenheit = 1.8 x...

  • Problem: A local amateur meteorologist has been recording daily high temperatures throughout the month of June....

    Problem: A local amateur meteorologist has been recording daily high temperatures throughout the month of June. He would like you to write a program to compute some statistics based on the data he has collected. He has placed each daily high temperature on a separate line in a file named “summer_temps.txt”. The high temperatures are in order so that the first one is for June 1, the second is for June 2, and so on. The statistics that the meteorologist...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT