Hey guys...
I have this code and i need to make the temperature part work with a function but i don't know how.
So
Any help is appreciated.
Thanks
*edit* Also, if there is any way to make this simpler, then please tell.
#include <iostream>
#include <time.h>
#include <string>
using namespace std;
int temp (int, int);
int main()
{
//Integers
int a;
float b = 0;
int c;
float d;
int e;
//Title and choosing what you want
cout << endl << " Welcome To The TCVM. " << endl;
cout << endl << " The [T]emperature [C]urrency [V]olume [M]ass [U]nit [C]onverter" << endl << endl << endl;
while (1)
{
system("pause");
system("cls");
cout << endl << "What would you like to convert? " << endl;
cout << endl << "1. [T]emperature. " << endl;
cout << endl << "2. [C]urrency. " << endl;
cout << endl << "3. [V]olume. " << endl;
cout << endl << "4. [M]ass. " << endl;
cout << endl << " ";
cin >> a;
//Temperatures
if (a == 1)
{
system("pause");
system("cls");
cout << " Ok, you want to convert temperatures. " << endl;
cout << " Please enter the temperature in Farenheit that you wish to convert: " << endl;
cin >> b;
b = temp (e, a);
cout <<"Here is the degree that you wanted converted in Celcius: " << endl;
cout <<b <<" degrees" << endl;
}
//Currency
else if (a == 2)
{
system("pause");
system("cls");
cout << endl <<" Ok, you want to convert Currency. " << endl;
cout << endl;
cout << " Please choose what currency you would like to convert to: " << endl;
cout << endl;
cout << " 1. Euro. " << endl;
cout << endl;
cout << " 2. U.K. Pound. " << endl;
cout << endl;
cout << " 3. Indian Rupee. " << endl;
cout << endl;
cout << " 4. Australian Dollar. " << endl;
cout << endl;
cout << " 5. Japanese Yen. " << endl;
cout << endl;
cout << " 6. Chinese Yuan Renminbi. " << endl;
cout << endl;
cin >> c;
if (c == 1)
{
system ("pause");
system ("cls");
cout << endl <<" Ok, Euro it is." << endl;
cout << endl;
cout << endl <<" Please enter the amount of U.S. Dollars that you would like converted: " << endl;
cout << endl;
cin >> d;
d = d * 0.69380;
cout << endl <<" The converted amount in Euros is: " << d << endl;
}
else if (c == 2)
{
system ("pause");
system ("cls");
cout << endl <<" Ok, the British Pound it is." << endl;
cout << endl <<" Please enter the amount of U.S. Dollars that you would like converted: " << endl;
cin >> d;
d = d * 0.60510;
cout << endl <<" The converted amount in Pounds is: " << d << endl;
}
else if (c == 3)
{
system ("pause");
system ("cls");
cout << endl <<" Ok, the Indian Rupee it is." << endl;
cout << endl <<" Please enter the amount of U.S. Dollars that you would like converted: " << endl;
cin >> d;
d = d * 45.2400;
cout << endl <<" The converted amount in Rupees is: " << d << endl;
}
else if (c == 4)
{
system ("pause");
system ("cls");
cout << endl <<" Ok, Australian Dollar it is." << endl;
cout << endl <<" Please enter the amount of U.S. Dollars that you would like converted: " << endl;
cin >> d;
d = d * 0.94971;
cout << endl <<" The converted amount in Australian Dollars is: " << d << endl;
}
else if (c == 5)
{
system ("pause");
system ("cls");
cout << endl <<" Ok, Japanese Yen it is." << endl;
cout << endl <<" Please enter the amount of U.S. Dollars that you would like converted: " << endl;
cin >> d;
d = d * 76.6102;
cout << endl <<" The converted amount in Yen is: " << d << endl;
}
else if (c == 6)
{
system ("pause");
system ("cls");
cout << endl <<" Ok, Chinese Yuan Renminbi it is." << endl;
cout << endl <<" Please enter the amount of U.S. Dollars that you would like converted: " << endl;
cin >> d;
d = d * 6.38710;
cout << endl <<" The converted amount in Chinese Yuan Renminbi is: " << d << endl;
}
}
}
system("pause");
return 0;
}
int temp(int a)
{
int e;
e = a - 32;
return(e)*.55;
}