Hello, I am trying to make a menu for my program that goes to a label depending on the letter entered. Any help would be much appreciated.
Here is my code:
#include <iostream>
#include <windows.h>
#include <cmath>
usingnamespace std;
double x, y;
string z, s, d;
string l = ("wget.exe "), k = ("color ");
int main()
{
e:
system("title OmniTool");
system("cls");
cout << ("Please choose a mode.") << endl;
cout << ("Press m to goto Multiplication") << endl;
cout << ("Press d to goto Division") << endl;
cout << ("Press a to goto Addition") << endl;
cout << ("Press s to goto Subtraction") << endl;
cout << ("Type sqr to goto SquareRoot") << endl;
cout << ("Press c to change color.") << endl;
cout << ("Press w to goto Website Downloader.") << endl;
cout << ("Press q to exit.") << endl;
cout << ("Mode: ");
cin >> d;
goto + d;
m:
system("cls");
cout << ("Multiplication") << endl;
cin >> x;
cin >> y;
cout << ("The answer is:") << x*y << endl;
Sleep(3000);
goto e;
d:
system("cls");
cout << ("Division") <<endl;
cin >> x;
cin >> y;
cout << ("The answer is:") << x/y << endl;
Sleep(3000);
goto e;
a:
system("cls");
cout << ("Addition") <<endl;
cin >> x;
cin >> y;
cout << ("The answer is:") << x+y << endl;
Sleep(3000);
goto e;
s:
system("cls");
cout << ("Subtraction") <<endl;
cin >> x;
cin >> y;
cout << ("The answer is:") << x-y << endl;
Sleep(3000);
goto e;
sqr:
system("cls");
cout << ("SquareRoot") << endl;
cin >> x;
sqrt(x);
cout << ("The answer is:") << y << endl;
Sleep(3000);
goto e;
w:
system("cls");
cout << ("Enter the URL for the website that you wish to download to download:") << endl;
cout << ("URL: ") << endl;
cin >> z;
l = l + z;
system(l.c_str());
goto e;
q:
return 0;
c:
system("cls");
cout << ("Console ColorChanger.") << endl;
cout << ("choose a console color:") << endl;
cout << ("0 = Black 8 = Gray") <<endl;
cout << ("1 = Blue 9 = Light Blue") <<endl;
cout << ("2 = Green A = Light Green") <<endl;
cout << ("3 = Aqua B = Light Aqua") <<endl;
cout << ("4 = Red C = Light Red") <<endl;
cout << ("5 = Purple D = Light Purple") <<endl;
cout << ("6 = Yellow E = Light Yellow")<<endl;
cout << ("7 = White F = Bright White") <<"\n";
cout << ("color: ");
cin >> s;
k = k + s;
system(k.c_str());
goto e;
}
And this the code I need help with is the code that is underlined and bold:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
system("title OmniTool");
system("cls");
cout << ("Please choose a mode.") << endl;
cout << ("Press m to goto Multiplication") << endl;
cout << ("Press d to goto Division") << endl;
cout << ("Press a to goto Addition") << endl;
cout << ("Press s to goto Subtraction") << endl;
cout << ("Type sqr to goto SquareRoot") << endl;
cout << ("Press c to change color.") << endl;
cout << ("Press w to goto Website Downloader.") << endl;
cout << ("Press q to exit.") << endl;
cout << ("Mode: ");
cin >> d;
goto + d; // get value for d and add it to the end of the "goto"
// function
What you've done here is attempt to replicate functions.
goto + d; // get value for d and add it to the end of the "goto"
This just makes no sense at all. goto is a keyword. It is not a function. It is not a variable. Trying to add something to it is completely nonsensical.
You're trying to mash features that already exist (functions) out of something wholly unsuitable. Why not just use functions?
well is there a similar function that can be used to goto another part of the program that can added onto to allow user input to determine the destination?