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

Write a program that requests the user to enter a Fahrenheit temperature. The pr

ID: 669717 • Letter: W

Question

Write a program that requests the user to enter a Fahrenheit temperature. The program should read the temperature as a type double number and pass it as an argument to a user-supplied function called Temperatures (). This function should calculate the Celsius equivalent and the Kelvin equivalent and display all three temperatures with a precision of two places to the right of the decimal. It should identify each value with the temperature scale it represents. Here is the formula for converting Fahrenheit to Celsius: Celsius = 5.0 / 9.0 * (Fahrenheit - 32.0) The Kelvin scale, commonly used in science, is a scale in which 0 represents absolute zero, the lower limit to possible temperatures. Here is the formula for converting Celsius to Kelvin: Kelvin = Celsius + 273.16 The Temperatures () function should use const to create symbolic representations of the three constants that appear in the conversions. The main() function should use a loop to allow the user to enter temperatures repeatedly, stopping when a q or other nonnumeric value is entered. Use the fact that scanf () returns the number of items read, so it will return l if it reads a number, but it won't return 1 if the user enters q. The == operator tests for equality, so you can use it to compare the return value of scanf () with

Explanation / Answer

#include <stdio.h>


void Temperatures(double temp)
{
   double celsius = (5.0/9.0)*(temp-32.0);
   double kelvin = celsius+273.16;
  
   printf("Temperature in celsius is %.2f ",celsius);
   printf("Temperature in kelvin is %.2f ",kelvin);
}

int main ()
{
  
   double temperature;
   char c;
   int temp;
   while(true)
   {
  
   printf("Enter the temperature in farenhite ");
  
   scanf("%lf",&temperature);
  
   Temperatures(temperature);
  
   printf("Do you want to continue ? ");
   scanf(" %c",&c);
  
   temp = c-'0';
  
  
   if(c=='q' || (temp>=0 && temp<=9))
       break;
   }
    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