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

Programming assignment 2 (Event-Controlled Loop): Use program CountUC for the ex

ID: 3690552 • Letter: P

Question

Programming assignment 2 (Event-Controlled Loop): Use program CountUC for the exercises in this assignment. // Program CountUC counts the number of uppercase letters // on a line. #include using namespace std; int main () { char letter; int letterCt; /* TO BE FILLED IN */ return 0; } Exercise 1: Fill in the body of program CountUC so that the number of uppercase letters on a line of input is printed. Run your program with the following input and show the results. Input Output AbbaDabbaDoo Exercise 2: Change program CountUC from Exercise 1 so that the counting stops if the input contains a digit. Run your program with the following input and show the results. Input Output ABBA1DABBA2Doo Exercise 3: Change program CountUC from Exercise 1 so that it counts uppercase and lowercase letters. Run your program with the following input and show the results. Input Output Abba#Dabba#2Doo Turn in: Your answers and codes for Exercise 1, Exercise 2, and Exercise 3.

Explanation / Answer

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main ()
{
char letter;
int letterCt;


cout << "Enter a letter" << endl;
cin >> letter;
letterCt = 0;
while (letter >= 'A' && letter <= 'Z'){
cout << "Enter a letter" << endl;
letterCt++;
cin >> letter;
}
cout << letterCt << endl;

return 0;
}