manytimes-3

Untitled

Oct 25th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     string name = "";
  7.     getline(cin, name);
  8.  
  9.     bool isValid = true;
  10.  
  11.     double totalNames = 0;
  12.     double validNames = 0;
  13.     double invalidNames = 0;
  14.  
  15.     while (true) {
  16.         isValid = true;
  17.         totalNames++;
  18.  
  19.         if (name == "Statistic")
  20.             break;
  21.  
  22.         for (int i = 0; i < name.length(); i++) {
  23.             if (!isalpha(name[i])) {
  24.                 cout << "Invalid name." << endl;
  25.                 invalidNames++;
  26.                 isValid = false;
  27.                 break;
  28.             }
  29.         }
  30.  
  31.         if (isValid) {
  32.             validNames++;
  33.  
  34.             name = to_string(toupper(num[0]));
  35.  
  36.             cout << name << endl;
  37.         }
  38.  
  39.         getline(cin, name);
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment