I know i ask alot of questions but as you can see I REALLY am a beginner. Let me just put straight out what it is im doing and what exactly i need help with.
Basically, I have to input two random initials, and then i have to see if the initial is uppercase or lowercase and what place number it has in the alphabet.
example:
If i enter y and Z:
Your first initial is lowercase and is the 25th letter in the alphabet.
Your second initial is uppercase and is the 26th letter in the alphabet.
Now i already know how to say if the letter is uppercase or lowercase. (thats been figured out already)
What i am really confused on is how in the world the st, nd, rd, and th would be incorporated into these positions.
If it was just two SET initials, I would have no trouble at all. But the reason i have trouble is because each letter is random.
also thank you in advance.
What i have so far( The second initial is commented out for now until i can even figure out what to do)
Also: (I have alot of cin.gets because with the program i use, if i dont input that. The compiled code will just shut off)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <iostream>
using namespace std;
int main()
{
char a;
//char b;
cout << "Please enter your initials." << endl;
cin >> a;
//cin >> b;
cin.get();
if (a >= 'a' && a <= 'z')
{
cout << "Your first initial is in lowercase." << endl;
}
else if (a >= 'A' && a <= 'Z')
{
cout << "Your first initial is in uppercase." << endl;
cin.get();
}
cin.get();
return 0;
}
|