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

Write a C++ program that takes in three arguments, a start temperature (in Celsi

ID: 3779566 • Letter: W

Question

Write a C++ program that takes in three arguments, a start temperature (in
Celsius), an end temperature (in Celsius) and a step size. Print out a table that goes
from the start temperature to the end temperature, in steps of the step size; you do
not actually need to print the final end temperature if the step size does not exactly
match. You should perform input validation: do not accept start temperatures less
than a lower limit (which your code should specify as a constant) or higher than an
upper limit (which your code should also specify). You should not allow a step size
greater than the difference in temperatures.

Explanation / Answer

#include <iostream>
#include <cstdlib>
using namespace std;

void temperatureTable(float start_temperature,float end_temperature,int step)
{
   float i;
   for(i=start_temperature;i<=end_temperature;i=i+step) //display table
   {
       cout<<endl<<i;
   }
  
}

int main()
{
float start_temperature,end_temperature;
int step =5;
cout<<" Enter start temperature and end tempertaure in celcius";
cin>>start_temperature;
if(start_temperature < 0)
{
cout<<" The start temperature should be greater than 0"; //validation for start temperature
exit(0);
}

cin>>end_temperature;
if(end_temperature > 100) //validation for end temperature
{
cout<<" The end temperature should not be greater than 100";
exit(0);
}
temperatureTable(start_temperature,end_temperature,step); //function call
return 0;
}

output:

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