Question

in c please

Write a program that estimates the temperature in a freezer (in C) given the elapsed time (hours) since a power failure. Assu

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

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks

//code

#include<stdio.h>

//method to find the temperature T using the given formula

float findTemperature(float time){

              //applying equation

              float temp=((4*time*time)/(time+2))-20;

              return temp;

}

int main(){

              //declaring variables

              int hours, minutes;

              float totalHours=0;

              //prompting user for hours and minutes

              printf("How long it has been since the start of power failure?\n");

              printf("Hours: ");

              scanf("%d",&hours);

              printf("Minutes: ");

              scanf("%d",&minutes);

              //assuming inputs are valid

              totalHours+=hours; //adding hours to total time

              totalHours+=(float) minutes/60.0; //adding minutes/60 to total time

              //finding temperature

              float temp=findTemperature(totalHours);

              //displaying temperature with a precision of 2 digits

              printf("Estimated temperature: %.2f degree celsius\n",temp);

              return 0;

}

/*OUTPUT*/

How long it has been since the start of power failure?

Hours: 2

Minutes: 30

Estimated temperature: -14.44 degree celsius

Add a comment
Know the answer?
Add Answer to:
in c please Write a program that estimates the temperature in a freezer (in C) given...
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
  • in c++ program Write a C + + program that prompts the user to input the...

    in c++ program Write a C + + program that prompts the user to input the elapsed time for an event in seconds. The program then outputs the elapsed time in hours, minutes, and seconds. (For example, if the elapsed time is 9630 seconds, then the output is 2:40:30.)

  • (a) A freezer maintains an interior temperature inside of -22.0°C and has a coefficient of performance of 3.00. The fre...

    (a) A freezer maintains an interior temperature inside of -22.0°C and has a coefficient of performance of 3.00. The freezer sits a room with a temperature of 25.0°C. The freezer is able to etely canvert 090 J/(9 °C), and the latent heat of & one minute. What input power (in watts) does the freezer require? (The specific heat of liquid water is 4.186 J/(g °C), liquid water at 25.0-tolce specific he ice is of water is 33 J/g.) W (b)...

  • Write a program in C that will convert all 12 months' average temperature from Celsius to...

    Write a program in C that will convert all 12 months' average temperature from Celsius to Fahrenheit. You need to create an array named aye jump and prompt the user to input average temperature in Celsius for all 12 months. After that, you need to develop a user temperatures from Celsius to Fahrenheit and pass the array as reference and convert all temperatures from Celsius to Fahrenheit. Next, compute the average temperature of the year and assign it to a...

  • A freezer maintains an interior temperature inside of −24.0°C and has a coefficient of performance of...

    A freezer maintains an interior temperature inside of −24.0°C and has a coefficient of performance of 3.00. The freezer sits in a room with a temperature of 19.0°C. The freezer is able to completely convert 26.0 g of liquid water at 19.0°C to ice at −24.0°C in one minute. What input power (in watts) does the freezer require? (The specific heat of liquid water is 4.186 J/(g · °C), the specific heat of ice is 2.090 J/(g · °C), and...

  • (a) A freezer maintains an interior temperature inside of −20.0°C and has a coefficient of performance...

    (a) A freezer maintains an interior temperature inside of −20.0°C and has a coefficient of performance of 3.00. The freezer sits in a room with a temperature of 15.0°C. The freezer is able to completely convert 36.0 g of liquid water at 15.0°C to ice at −20.0°C in one minute. What input power (in watts) does the freezer require? (The specific heat of liquid water is 4.186 J/(g · °C), the specific heat of ice is 2.090 J/(g · °C),...

  • 12. 13. Write a program that prompts the capacity, in gallons, of an automobile fuel tank...

    12. 13. Write a program that prompts the capacity, in gallons, of an automobile fuel tank and the miles per gallon the automobile can be driven. The program outputs the number of miles the automobile can be driven without refueling Write a C++ program that prompts the user to input the elapsed time for an event in seconds. The program then outputs the elapsed time in hours, minutes, and seconds. (For example, if the elapsed time is 9630 seconds, then...

  • Write a C++ program that prompts a user to enter a temperature in Fahrenheit as a...

    Write a C++ program that prompts a user to enter a temperature in Fahrenheit as a real number. After the temperature is entered display the temperature in Celsius. Your program will then prompt the user if they want to continue. If the character n or N is entered the program will stop; otherwise, the program will continue. After your program stops accepting temperatures display the average of all the temperatures entered in both Fahrenheit and Celsius. Be sure to use...

  • C++ Question 6 (10pt): Convert seconds Write a program that takes a number of seconds as...

    C++ Question 6 (10pt): Convert seconds Write a program that takes a number of seconds as user input (as an integer) and converts it to hours, minutes, and seconds as shown below. You should convert the amount of time in such a way that maximizes the whole numbers of hours and minutes. Expected output 1 (bold is user input) Enter a number of seconds: 60 0 hour(s) 1 minute(s) 0 second(s) Expected output 2 (bold is user input) Enter a...

  • Write a program in C++. You need everything everythihng given You will create a function that...

    Write a program in C++. You need everything everythihng given You will create a function that validates input. It should accept only non-negative integers. If the input is incorrect the function should throw an exception. The exception will not be caught in the function. You will create a function that reads in 2 integer values. One is a number that will be raised to the power of the second. So if 5 and 6 are entered the result would be...

  • How do I program this problem using c++. Create a process to prompt the user to...

    How do I program this problem using c++. Create a process to prompt the user to enter the number of seconds and determine the whole number of days, hours, minutes, and seconds corresponding to the entered number of seconds. For example if the number of seconds entered was 183945, then 2 days, 3 hours, 5 minutes and 45 seconds should be displayed. There are 86400 seconds in a day, 3600 seconds in an hour, and 60 seconds in a minute....

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