I am new to programming and need help at probably the easiest bit of my project.
my assignment is to create a blackjack game, however it is with menu system i am already struggling.
i need help with picking the options from the main menu.
any help will be greatly appreciated
EDIT: i have attempted a switch but am very new and as expected it did not work
Here is a small Factorial program, that uses the switch statement. Entering 1 or 2, sends you to the rules routine, 3 to 7, prints out the inputted variable and the default prints out the number with the factorial. Hopefully, this can help you set up your program, with the switch statement. Good luck.
#include <iostream>
usingnamespace std;
int factorial (int);
void rules();
int main()
{
int result;
cout << "Enter your number: ";
cin >> result;
switch(result)
{
case 1:
case 2:
rules();
break;
case 3:
cout << "The factorial of three is "<< factorial (result);
break;
case 4:
cout << "The factorial of four is "<< factorial (result);
break;
case 5:
cout << "The factorial of five is "<< factorial (result);
break;
case 6:
cout << "The factorial of six is "<< factorial (result);
break;
case 7:
cout << "The factorial of seven is "<< factorial (result);
break;
default:
cout << "Factorial of " << result << " is "<< factorial (result) << endl;
}
cout << endl << endl;
}
void rules()
{
cout << "A one or two, returns the same values inputted." << endl <<"Next time, try a higher number..";
}
int factorial (int n)
{
int fact = 0;
if (n <= 1)
return 1;
else
fact = n * factorial (n - 1);
return fact;
}