1. ## Celsius to Farenheit task

Code:
```#include <iostream>

using namespace std;

int main()
{
cout<< "Roll Cast's Celsius to Farenheit Converter\n Please enter the minimum temperature in celsius\n";
double min;
cin>> min;
jump:
cout<< "Please enter the maximum temperature in celsius\n";
double max;
cin>> max;
cout<< "Please enter the number of steps for the temperature range, non zero integer\n";
int steps;
cin>> steps;

if (min > max);
{cout<< "Your values for max. and min. temperature are impossible please re-enter them.\n";
goto jump;
}

cout<<"Press ENTER to continue\n";
cin.get();
cin.ignore();
return 0;
}```
This is the code I have written so far, I haven't looked at the correct solution yet, this basically collects the users inputs and makes sure they are possible, ie. min < max. However when it gets to the goto and it re asks for the min and max it doesn't ask for the no. of steps and just goes into a loop by asking for the 2 inputs over and over.

2. ... This is why the use of goto is discouraged ...

What, a loop was too complicated for you?

EDIT: And, remove that semicolon in line 18

3. So I could use a loop and break the loop when the inputs are correct?

4. Originally Posted by roll cast
So I could use a loop and break the loop when the inputs are correct?
That or loop while the inputs are wrong.

5. Code:
```#include <iostream>

using namespace std;

int main()
{
double max, min;
int steps;
cout<< "RollCast's Celsius to Farenheit Converter \n";
do
{
cout<< "Please enter the max. temp. in celsius.\n";
cin>> max;
cout<< "Please enter the min. temp. in celsius\n";
cin>> min;
cout<< "Please enter the number of steps for the range\n";
cin>> steps;
if (min <= max && steps >= 0)
break;
cout<< "The values you have entered are wrong please check them and re-enter\n";
}
while ((min > max || steps < 0));
cout<< "Press ENTER to continue";
cin.get();
cin.ignore();
return 0;
}```
I changed the goto for a do while loop and have added conditionals which ensures that min is always less than or equal to max and that the number of steps between min and max is always a number greater than zero.

6. Code:
```#include <iostream>

using namespace std;

int main()
{
double max, min;
int steps;
cout<< "RollCast's Celsius to Farenheit Converter \n";
do
{
cout<< "Please enter the max. temp. in celsius.\n";
cin>> max;
cout<< "Please enter the min. temp. in celsius\n";
cin>> min;
cout<< "Please enter the number of steps for the range\n";
cin>> steps;
if (min > max || steps < 0)
{
cout<< "The values you have entered are wrong please check them and re-enter\n";
}

}
while ((min > max || steps < 0));
cout<< "Press ENTER to continue";
cin.get();
cin.ignore();
return 0;
}```
I edited the code to remove the break as I just realised that it is similar to goto

7. I have finished the conversion and step part of the code but I think I have used a number of work around which are probably not very good practice?

Code:
```#include <iostream>

using namespace std;

int main()
{
double maxc, minc, maxf, minf, stepc, stepfv, stepcv;
int steps;
cout<< "RollCast's Celsius to Farenheit Converter \n";
do
{
cout<< "Please enter the max. temp. in celsius.\n";
cin>> maxc;
cout<< "Please enter the min. temp. in celsius\n";
cin>> minc;
cout<< "Please enter the number of steps for the range\n";
cin>> steps;
if (minc > maxc || steps < 0)
{
cout<< "The values you have entered are wrong please check them and re-enter\n";
}

}
while ((minc > maxc || steps < 0));

if (steps == 0)
{
maxf = 1.8 * maxc + 32;
minf = 1.8 * minc + 32;
cout<< "Max. Temp. in F ="<< maxf <<endl;
cout<< "Min. Temp. in F ="<< minf << endl;
}

else
{
int stepdiv = steps += 1;

for (int i = 0; i < steps; i++)
{
if (i == 0)
{
maxf = 1.8 * maxc +32;
cout<< "Max. Temp. in F ="<< maxf <<endl;
}
if (i != 0)
{
stepc = (maxc - minc)/ stepdiv;
stepcv = maxc - (stepc * i);
stepfv = 1.8 * stepcv + 32;
cout<< "Step in F ="<< stepfv<< endl;
}
if (i + 1 == steps)
{
minf = 1.8 * minc + 32;
cout<< "Min. Temp. in F ="<< minf <<endl;
}
}
}

cout<< "Press ENTER to continue";
cin.get();
cin.ignore();
return 0;
}```