I have a couple of questions to ask and i would be really thankful if they were answered.
1. How do you let the user input text or numbers.etc
2. Would this code be okay to convert over
Code: Select all
/*
This is a simple but long conversion program. Made By Gavin Pacini at the age of 11 on the 25th and 26th of January 2008
*/
#include <iostream>
using namespace std;
float startvar, liquid, dis;
int money;
char color2[80];
int main()
{
cout << "To start please select a color,\nEnter the word color then a space then a letter from a-f followed by a number\nfrom 1-9, eg. color D5 (enter)\n";
gets(color2); // saves input for color
system("pause");
start:
system("cls");// clear screen
system(color2);// What color to display
cout << "Hello and welcome to my easy conversion table, made by Gavin Pacini.\n"; // Welcome to program
system("pause");
cout << "To start please press a number that matches your category.\n";
cout << "Press:\n 1 for money,\n 2 for liquid,\n 3 for distance.\n Follwed by Enter.\n"; // Start of table
cin >> startvar;
if (startvar == 1) goto money;
if (startvar == 2) goto liquid;
if (startvar == 3) goto distance; // goto statement for start
// start of money table
money:
cout << "Now what kind of currency do you want?\n";
cout << "Press:\n 1 for euro to dollar,\n 2 for euro to sterling,\n 3 for dollar to sterling,\n 4 for dollar to euro,\n 5 for sterling to euro,\n 6 for sterling to dollar.\n"; // ask for money table
cin >> money;
if (money == 1) goto ed;
if (money == 2) goto es;
if (money == 3) goto ds;
if (money == 4) goto de;
if (money == 5) goto se;
if (money == 6) goto sd; // goto statement for money
float ewd, d1, ews, s1, dws, s2, dwe, e1, swe, e2, swd, d2;
//euro to dollar using $1
ed:
cout << "Please enter an amount of euros.\n";
cin >> ewd;
d1 = ewd * 1.47;
cout << "\nDollars: " << d1 <<"\n";
system("pause");
goto start;
//euro to sterling using £1
es:
cout << "Please enter an amount of euros.\n";
cin >> ews;
s1 = ews * .74;
cout << "\nSterling: " << s1 <<"\n";
system("pause");
goto start;
//dollar to sterling using £2
ds:
cout << "Please enter an amount of dollars.\n";
cin >> dws;
s2 = dws * .504;
cout << "\nSterling: " << s2 <<"\n";
system("pause");
goto start;
//dollar to euro using €1
de:
cout << "Please enter an amount of dollars.\n";
cin >> dwe;
e1 = dwe / 1.47;
cout << "\nEuros: " << e1 <<"\n";
system("pause");
goto start;
//sterling to euro using €2
se:
cout << "Please enter an amount of sterling.\n";
cin >> swe;
e2 = swe * 1.34;
cout << "\nEuro: " << e2 <<"\n";
system("pause");
goto start;
// sterling to dollar using $2
sd:
cout << "Please enter an amount of sterling.\n";
cin >> swd;
d2 = swd / 1.98;
cout << "\nDollars: " << d2 <<"\n";
system("pause");
goto start;
// End of money Table
// Start of liquid Table
liquid:
cout << "Now what kind of liquid do you want?\n";
cout << "Press:\n 1 for gallons to litres,\n 2 for gallons to pints,\n 3 for litres to gallons,\n 4 for litres to pints,\n 5 for pints to litres,\n 6 for pints to gallons.\n"; //asks for liquid table
cin >> liquid;
if (liquid == 1) goto gl;
if (liquid == 2) goto gp;
if (liquid == 3) goto lg;
if (liquid == 4) goto lp;
if (liquid == 5) goto pl;
if (liquid == 6) goto pg;
float gwl, l1, gwp, p1, lwg, g1, lwp, p2, pwl, l2, pwg, g2;
//gallons to litres using l1 (not 11)
gl:
cout << "Please enter an amount of gallons.\n";
cin >> gwl;
l1 = gwl * 3.7854;
cout << "\nLitres: " << l1 <<"\n";
system("pause");
goto start;
//gallons to pints using p1
gp:
cout << "Please enter an amount of gallons.\n";
cin >> gwp;
p1 = gwp * 8;
cout << "\nPints: " << p1 <<"\n";
system("pause");
goto start;
//litres to gallons using g1
lg:
cout << "Please enter an amount of litres.\n";
cin >> lwg;
g1 = lwg / 3.7854;
cout << "\nGallons: " << g1 <<"\n";
system("pause");
goto start;
//litres to pints using p2
lp:
cout << "Please enter an amount of litres.\n";
cin >> lwp;
p2 = lwp / .454;
cout << "\nPints: " << p2 <<"\n";
system("pause");
goto start;
//pints to litres using l2 (not 12)
pl:
cout << "Please enter an amount of pints.\n";
cin >> pwl;
l2 = pwl * .454;
cout << "\nLitres: " << l2 <<"\n";
system("pause");
goto start;
//pints to gallons using g2
pg:
cout << "Please enter an amount of pints.\n";
cin >> pwg;
g2 = pwg / 8;
cout << "\nGallons: " << g2 <<"\n";
system("pause");
goto start;
//End of liquid table
//Start of distance table
distance:
cout << "Now what distance do you want?\n";
cout << "Press:\n 1 for Miles to Km,\n 2 for Km to Miles.\n";
cin >> dis;
float mwk, k1, kwm, m1;
if (dis == 1) goto mk;
if (dis == 2) goto km;
// Miles to Kilmetres using k1
mk:
cout << "Please enter an amount of miles.\n";
cin >> mwk;
k1 = mwk / .625;
cout << "\nKilometres: " << k1 <<"\n";
system("pause");
goto start;
// Kilometers to Miles using m1
km:
cout << "Please enter an amount of kilometres.\n";
cin >> kwm;
m1 = kwm * .625;
cout << "\nMiles: " << m1 <<"\n";
system("pause");
goto start;
return 0;
}
Please note that this is one of my first apps and works fine on the pc (only tried on windows).
I am using the PSPDev Win32 app and have updated it to the highest thanks in advanced.
Gavin/ITDemo