Click here to Skip to main content
15,922,419 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Random Name Generator Pin
David Crow14-Aug-09 7:53
David Crow14-Aug-09 7:53 
GeneralRe: Random Name Generator Pin
Chuck Vought14-Aug-09 9:31
Chuck Vought14-Aug-09 9:31 
QuestionRe: Random Name Generator Pin
David Crow14-Aug-09 9:36
David Crow14-Aug-09 9:36 
GeneralRe: Random Name Generator Pin
Chuck Vought14-Aug-09 9:40
Chuck Vought14-Aug-09 9:40 
GeneralRe: Random Name Generator Pin
Chuck Vought14-Aug-09 9:45
Chuck Vought14-Aug-09 9:45 
QuestionRe: Random Name Generator Pin
David Crow14-Aug-09 9:47
David Crow14-Aug-09 9:47 
AnswerRe: Random Name Generator Pin
Chuck Vought14-Aug-09 9:52
Chuck Vought14-Aug-09 9:52 
AnswerRe: Random Name Generator Pin
Chuck Vought14-Aug-09 10:26
Chuck Vought14-Aug-09 10:26 
int main()
{	
	
	int  numFirst, numLast,num,i,j,count;
	int lowFirst=3, highFirst=12,lowLast=5, highLast=14;
		

		cout << "This program will generate first and last names from\n";
		cout <<"the number of names you choose." << endl;
		 	  
		cout << endl;
		cout << "Please enter the number of names between 1 and 100 you want to \n"
			 << "generate random first and last names for: ";
		cin >> num;

		while (num < 1 || num > 100)
		{
			cout << "\nInvalid number entered!!  Please try again ..." << endl << endl;
			cout << "Please enter the number of integers between 1 and 100 you want to\n"
				<< "generate random first and last names for: ";
			cin >> num;
		}

		cout << "\nPlease enter the number of letters(between 3 and 12) you want for your first name: ";
		cin >> numFirst;
		cout << endl;

		while (numFirst < lowFirst || numFirst > highFirst)
		{
			cout << "\nInvalid number entered!!  Your number must be between 3 and 12. \n"
				 << "Please re-enter a number. \n";
			cin >> numFirst;
			
		}

		cout << "\nPlease enter the number of letters(between 5 and 14) you want for your last name: ";
		cin >> numLast;
		cout << endl;

		while (numLast < lowLast || numLast > highLast)
		{
			cout << "\nInvalid number entered!!  Your number must be between 5 and 14. \n"
				 << "Please re-enter a number.\n";
			cin >> numLast;
		}
		
		string firstname[num],lastname,name;	
		static const int namelen = numFirst;	
		static const char* letters[2] = { "bcdfghjklmnpqrstvwxyz", "aeiouy" };
		static const  int letterlength[2] = { strlen(letters[0]), strlen(letters[1]) };
		srand(time(NULL));
		
		for (int j=0; j<num; j++)
		{
				for (int i=0; i<numFirst; i++)
				{
					
					name += letters[i%2][rand()%letterlength[i%2]];
					
				}
				
				name[0]=toupper(name[0]);
				firstname[j]=name;
				name = "";
							
		}
			
				for (int i=0; i<numLast; i++)
				{
					lastname[i] += letters[i%2][rand()%letterlength[i%2]];
					lastname[0] = toupper(lastname[0]);
				}

				for(j=0;j<num;j++)
				{
					cout <<firstname[j].c_str() <<" ";
					if(j<=5)
					{ 
						cout<<endl;
					}
				}

cout<<endl<<endl;
return 0;
}

GeneralRe: Random Name Generator Pin
David Crow14-Aug-09 10:37
David Crow14-Aug-09 10:37 
GeneralRe: Random Name Generator Pin
Chuck Vought14-Aug-09 11:00
Chuck Vought14-Aug-09 11:00 
QuestionRe: Random Name Generator Pin
David Crow14-Aug-09 11:04
David Crow14-Aug-09 11:04 
AnswerRe: Random Name Generator Pin
Chuck Vought14-Aug-09 11:11
Chuck Vought14-Aug-09 11:11 
GeneralRe: Random Name Generator Pin
David Crow14-Aug-09 11:13
David Crow14-Aug-09 11:13 
GeneralRe: Random Name Generator Pin
Chuck Vought14-Aug-09 11:19
Chuck Vought14-Aug-09 11:19 
GeneralRe: Random Name Generator Pin
Chuck Vought14-Aug-09 15:12
Chuck Vought14-Aug-09 15:12 
GeneralRe: Random Name Generator Pin
David Crow15-Aug-09 5:20
David Crow15-Aug-09 5:20 
AnswerRe: Random Name Generator Pin
Chuck Vought14-Aug-09 10:19
Chuck Vought14-Aug-09 10:19 
GeneralRe: Random Name Generator Pin
David Crow14-Aug-09 10:27
David Crow14-Aug-09 10:27 
GeneralRe: Random Name Generator Pin
Chuck Vought14-Aug-09 10:36
Chuck Vought14-Aug-09 10:36 
GeneralRe: Random Name Generator Pin
sashoalm15-Aug-09 4:20
sashoalm15-Aug-09 4:20 
GeneralRe: Random Name Generator Pin
Chuck Vought15-Aug-09 13:35
Chuck Vought15-Aug-09 13:35 
Questionflowing strings on BMP image of SDI View window? Pin
rambojanggoon12-Aug-09 21:39
rambojanggoon12-Aug-09 21:39 
AnswerRe: flowing strings on BMP image of SDI View window? Pin
KarstenK12-Aug-09 22:04
mveKarstenK12-Aug-09 22:04 
Questionhow to display many picture in 1 dialog Pin
DevelopmentNoob12-Aug-09 19:32
DevelopmentNoob12-Aug-09 19:32 
AnswerRe: how to display many picture in 1 dialog Pin
DevelopmentNoob12-Aug-09 19:42
DevelopmentNoob12-Aug-09 19:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.