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

Calculate in 10o increments stating with 32o F (Fahrenheit), the corresponding t

ID: 3733580 • Letter: C

Question

Calculate in 10o increments stating with 32o F (Fahrenheit), the corresponding temperature for Celsius and Kelvin.

oF   oC   K

32

42

52

62

72

82

92

102

112

122

132

142

152

162

172

182

192

202

212

Program Requirements:

Use a loop, your choice.

Calculate and display the temperatures in three columns with a table heading to the monitor.

The program should send the output of the results to a data file. The name is specified by the end user.

Do NOT use an array (this note is aimed at those who already are familiar with an Array) for this assignment.

Explanation / Answer

As per your requirement the below one is solution please follow it

#include <iostream>
#include <fstream>
using namespace std;
int main()
{
   int fahrenheit;
   float celsius,kelvin;//variable decleration
   ofstream myfile;//creating file to copy data
   myfile.open ("example.txt");
   myfile<<"°F"<<" "<<"°C"<<" "<<"K"<<endl;//printing table header
   for(fahrenheit=32;fahrenheit<=212;fahrenheit=fahrenheit+10){//loop to convert temperature
       celsius=(fahrenheit-32)*0.5556;//fahrenheit to celsius
       kelvin= (fahrenheit + 459.67)*0.5556; //fahrenheit to kelvin
       myfile<<fahrenheit<<" "<<celsius<<" "<<kelvin<<endl;//writing the output  
   }
   myfile.close();
   return 0;
}

output:

°F   °C   K
32   0   273.172
42   5.556   278.728
52   11.112   284.284
62   16.668   289.84
72   22.224   295.396
82   27.78   300.952
92   33.336   306.508
102   38.892   312.064
112   44.448   317.62
122   50.004   323.176
132   55.56   328.732
142   61.116   334.288
152   66.672   339.844
162   72.228   345.4
172   77.784   350.956
182   83.34   356.512
192   88.896   362.068
202   94.452   367.624
212   100.008   373.18

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