Just started to learn C++ and i'm having an issue with getting a function to loop... not really sure if i'm even doing it right! Any help would be greatly appreciated.
To give some context, i'm trying to build a simple degrees to farenheit converter which takes a user input for the value in degrees and outputs a value in farenheit. Also, like in python where you can use: time.sleep()
to set a delay between messages, can you do that in C++?
Here's what i've managed to do so far:
#include <iostream>
using namespace std;
//-------------------------------------------------
void DegreesToFarenheit()
{
//Declaration
float Degrees, Farenheit;
//User Prompt
cout << "Please Enter a Temperature in Degrees: " << endl;
cin >> Degrees;
cout << "" << endl;
cout << "" << endl;
//Program
Farenheit = (((Degrees * 9)/5) + 32);
cout << Degrees << " Degrees" << " is " << Farenheit << " Farenheit";
cout << "" << endl;
}
char RepeatPrompt()
{
char Ans;
cout << "Would you like to enter a new value? ";
cin >> Ans;
cout << "" << endl;
if(Ans = "y" or "Y")
{DegreesToFarenheit();}
else if(Ans = "n" or "N")
{return 0;}
else
{main();}
}
int main()
{
cout << "Degrees To Farenheit Converter V1.0" << endl;
cout << "----------------------------------------" << endl;
DegreesToFarenheit() ;
RepeatPrompt() ;
return 0;
}