Well i'm forced to use the current funtions, loops etc. The code is not passing me any errors/warnings anymore during compilation, case is properly reading user input however isn't calling the function ;/ i've got no damn idea why and where to look further to solve the issue. I'll be greatfull if anyone could help me out with it pointing where is the issue and how possible i can solve the issue without changing the whole code.
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
#include <string.h>
#include <stdio.h>
char name[2], forname[15], username[2];
int number, fact;
//Functions
void showMenu();
int get_names();
int create_username(char name[10],char forname[15]);
int display_username(char username[2]);
int get_number();
int factorial(int number);
int display_factorial(int fact);
int main()
{
clrscr();
cout << "Welcome to the EPOS Options Ltd. \n"
<< "Network Administration & Statistics Department's \n"
<< "Pilot 'One Stop Shop' interface \n \n";
int OPTION_CHOICE; //menu choice
//constants for menu choices
constint USERNAME_CHOICE = 1,
FACTORIAL_CHOICE = 2,
QUIT_CHOICE = 3;
do
{
showMenu(); // Callout menu function
cin >> OPTION_CHOICE;
//Validate menu selection
while (OPTION_CHOICE < USERNAME_CHOICE || FACTORIAL_CHOICE > QUIT_CHOICE)
{
cout << "Please enter a valid menu choice: \n";
cin >> OPTION_CHOICE;
}
//If user doen't want to exit the application
if (OPTION_CHOICE != QUIT_CHOICE)
{
switch (OPTION_CHOICE)
{
case USERNAME_CHOICE:
cout << "You have choosen option 1 \n";
int display_username();
break;
case FACTORIAL_CHOICE:
cout << "You have choosen option 2 \n";
int display_factorial();
break;
}
}
} while (OPTION_CHOICE != QUIT_CHOICE);
cout << "\n Thank You for using this application, and goodbye!";
getch();
return 0;
}
//Menu Function
void showMenu()
{
cout <<"Please choose one of the following options \n \n"
<<"Option 1: To generate a personal username \n"
<<"Option 2: To calculate a number's factorial \n"
<<"Option 3: To Exit the application \n";
}
//Username Function
int get_names()
{
char name[10];
char forname[15];
cout << "Please enter Your first name \n";
cin >> name;
cout << "Please enter Your second name \n";
cin >> forname;
create_username(name,forname);
return create_username();
}
int create_username(char name[1],char forname[1])
{
puts (username);
strcpy(username,name);
strcat(username,forname);
display_username(username);
return display_username();
}
int display_username(char username[2])
{
cout << "Your Username is " << username << ". \n";
getch();
return main();
}
//Fractional's number function
int get_number()
{
cout << "Please enter a number \n";
cin >> number;
factorial(number);
return factorial();
}
int factorial(int number)
{
for(int i=1;i<=number;i++)
{
fact=fact*i;
}
display_factorial(fact);
return display_factorial();
}
int display_factorial(int fact)
{
cout << "/n The Factorial of " << number << " is " << fact << endl;
return main();
}