My assignment is to develop a C++ program to count the number of capital letters in a given string. String will be entered by user. The idea is to build my knowledge of loops and loop terminations.
I've got the basics down (I think) but I just don't get what functions or commands I need to use to go through the keyboard-input string character by character. We're not supposed to know the isupper function yet, so I'm supposed to use a get. function of some kind.
#include <iostream>
#include <string>
#include <iomanip>
namespace std;
int main()
{
char lettr;
int charactrCtr = 0;
int length;
int count = 0;
string userInput;
cout << "Enter a stream of characters, both capital and lower case, then press return..." << endl;
getline(cin, userInput);
length = userInput.length();
cout << length << endl;
while (getline(userInput, 3000).good
{
if ((lettr >= 65) && (lettr <= 90));
charactrCtr = charactrCtr + 1;
count = count + 1;
}
cout << "The number of capital letters in the sequence you entered is " << charactrCtr << endl;
return 0;
} // end of main