Well, I'm having trouble compiling - something is wrong with a static cast that tried to put together... also - could you guys help me double check my program's logic? I'm not sure the program is going to act like it is supposed to. So here's the order of operation that I want: Get user input, check for a letter, tell if said letter is uppercase or lowercase, check for a vowel, and then output the letter as lowercase at the end.
Using a ton of if statements always seems to confuse me!
EDIT: along with confusing me - I can never get clean formatting when I use them.
Here's the code - with errors after:
Code:
#include <cstdlib>
#include <iostream>
#include <cctype>
using std::cout;
using std::cin;
using std::endl;
int main()
{
char letter;
cout <<"Please enter a letter on your keyboard: ";
cin >> letter;
cout << endl;
if(std::isalpha(letter)) {
if(std::isupper(letter)) {
cout <<" Letter is uppercase\n";
}
if(std::islower(letter)) {
cout <<" Letter is lowercase.\n";
}
static_cast<char>(std::toupper(letter)) <<endl;
if(letter == 'A' || 'E' || 'I' || 'O' || 'U' || 'Y') {
cout <<"Your letter is a vowel.\n";
}
else{
cout <<"Your letter is not a vowel.\n";
}
static_cast<char>(std::tolower(letter)); <<endl;
cout <<"The letter was: " << letter;
}
system("PAUSE");
return EXIT_SUCCESS;
}
Errors are as follows:
Code:
C:\Dev-Cpp\letters.cpp In function `int main()':
26 C:\Dev-Cpp\letters.cpp invalid operands of types `char' and `<unknown type>' to binary `operator<<'
35 C:\Dev-Cpp\letters.cpp expected primary-expression before '<<' token
C:\Dev-Cpp\Makefile.win [Build Error] [letters.o] Error 1