Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming language is C++: Write a program that: a. Asks the user for an input

ID: 3759942 • Letter: P

Question

Programming language is C++:

Write a program that:

a. Asks the user for an input. The input can be anything, alphanumeric and symbols, can included spaces, and can be lowercase and uppercase.

b. Check if the string contains an alphanumeric character and display the result.

c. Check if the string contains an alphabetic character and display the result.

d. Check if the string contains a numeric character and display the result.

e. Check if the string contains a symbol character and display the result.

f. Check if the string contains a lowercase character and display the result.

g. Check if the string contains an UPPERCASE character and display the result.

Explanation / Answer

#include <iostream>
using namespace std;
int main()
{
char s[50];
int i;
int lowercase = 0;
int uppercase = 0;
int number = 0;
int other = 0;
cout <<"Enter string of characters with no blank spaces" << endl;
cout << "(example: aCb@#$%2)" << endl << endl;
cout << "Enter string: ";
cin >> s;
cout << endl;
i = 0;
while (s[i] != 0)
{
if ((s[i] >= 'a' && s[i] <= 'z'))
{
lowercase++;
i++;
}
else if ((s[i] >= 'A' && s[i] <= 'Z'))
{
uppercase++;
i++;
}
else if ((s[i] >= '0' && s[i] <= '9')) {
number++;
i++;
}
else
other++;
i++;
}
cout << "Your string has " << lowercase << " lower case letter(s)" << endl;
cout << "Your string has " << uppercase << " upper case letter(s)" << endl;
cout << "Your string has " << number << " number(s)" << endl;
cout << "Your string has " << other << " other character(s)" << endl;
system ("pause");
return 0;  
}