I am trying to get the following code to take in either a number or an integer, determine whether what the user inputted is an integer or a letter, and then print a random digit if it is an integer, or a random letter if it is a letter.
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cctype>
using namespace std;
/*
IGNORE THIS FUNCTION
int random()
{
int random;
srand(time(0) * 2345738 * 345478 * 34534 * 347562834 * 345643 * 345349);
cout << rand() << "\n" << endl;
cin >> random;
cout << "\n" << random << "\n" << endl;
return random;
}
*/
int numout(int x)
{
short int random;
srand(x);
random = time(0) * 123456789;
if(random >= 0 || random < 3200)
cout << "5";
if(random >= 3200 || random < 6400)
cout << "6";
if(random >= 6400 || random < 9600)
cout << "1";
if(random >= 9600 || random < 12800)
cout << "2";
if(random >= 12800 || random < 16000)
cout << "3";
if(random >= 16000 || random < 19200)
cout << "4";
if(random >= 19200 || random < 22400)
cout << "7";
if(random >= 22400 || random < 25600)
cout << "8";
if(random >= 25600 || random < 6400)
cout << "9";
if(random >= 3200 || random < 6400)
cout << "0";
}
int alphaout(int x)
{
short int random;
srand(x);
random = time(0) * 123456789;
if(random > 0 || random < 1000)
cout << "A";
else if(random >= 1000 || random < 2000)
cout << "B";
else if(random >= 2000 || random < 3500)
cout << "C";
else if(random >= 3500 || random < 4500)
cout << "D";
else if(random >= 4500 || random < 5500)
cout << "E";
else if(random >= 5500 || random < 7000)
cout << "F";
else if(random >= 7000 || random < 8000)
cout << "G";
else if(random >= 8000 || random < 9000)
cout << "H";
else if(random >= 10000 || random < 11000)
cout << "I";
else if(random >= 11000 || random < 12500)
cout << "J";
else if(random >= 12500 || random < 13500)
cout << "K";
else if(random >= 13500 || random < 14500)
cout << "L";
else if(random >= 14500 || random < 15500)
cout << "M";
else if(random >= 15500 || random < 16000)
cout << "N";
else if(random >= 16000 || random < 17000)
cout << "O";
else if(random >= 17000 || random < 18000)
cout << "P";
else if(random >= 18000 || random < 19000)
cout << "Q";
else if(random >= 19000 || random < 20000)
cout << "R";
else if(random >= 20000 || random < 21500)
cout << "S";
else if(random >= 21500 || random < 23000)
cout << "T";
else if(random >= 23000 || random < 24000)
cout << "U";
else if(random >= 24000 || random < 25000)
cout << "V";
else if(random >= 25000 || random < 26500)
cout << "W";
else if(random >= 26500 || random < 28000)
cout << "X";
else if(random >= 28000 || random < 29500)
cout << "Y";
else
cout << "Z";
}
int ifalpha(int x)
{
if(isalpha(x) == true)
return 0;
if(isalpha(x) == false)
return 1;
}
int main()
{
int a;
cin >> a;
switch(ifalpha(a))
{
case 0:
alphaout(a); break;
case 1:
numout(a); break;
}
system("PAUSE");
}
Any ideas?