Академический Документы
Профессиональный Документы
Культура Документы
1.) Create a C++ program that will input 10 alphabetic characters and output how many of the
characters entered were vowels and consonants. Display an error message if the character
entered is INVALID.
Criteria Score
Total 100
_______________________ _______________
Engr. Cristina A. Pascua Date
CS10-2L Computer Fundamentals and Programming Laboratory
File Name:
Answer Sheet:
#include <iostream>
#include <cctype> // to enbale the lowercase and the uppoercase values
#include <windows.h> // to enable the cls function
do
{
system ("cls"); // to clear after the loop
cout << "This Program allows the user to input Aphanumeric characters
and determine" << endl;
cout << "how many consonant and vowels there are" << endl;
cout << "and will indicate if it is invalid."<<endl;
cout << endl << "Please enter 10 Alphanumeric Characters: " << endl;
ctr=1; //counter
ctrvowel=0; // counter for vowel
ctrcons=0; // counter for consonant
for(alpha >= 'A' && alpha <= 'A', ctr=1, ctrvowel=0, ctrcons=0; ctr<=10; ctr++)
{ cin>>alpha;
alpha = toupper (alpha);
if(alpha == 'A' || alpha == 'E' || alpha == 'I' || alpha == 'O' || alpha == 'U')
ctrvowel++; // to count how many vowels
else if (alpha >= 'A' && alpha <= 'Z')
ctrcons++; // to count how many consonants
else
cout << "Invalid" << endl; // if the character is invalid
}
cout<<"Vowel = "<<ctrvowel<<endl;
cout<<"Consonant = "<<ctrcons<<endl;
}
while(tryagain=='Y'); // to loop the program
cout<<"Do you want to try again? [Y/y] ";
cin>>tryagain;
tryagain = toupper(tryagain);
FLOWCHART
START
Declarations
Char alpha, tryagain
Num ctr, ctrvowel, ctrcons
ctr=1;
ctrvowel=
0;
ctrcons=0;
Input Letter
if(alpha == 'A' ||
alpha == 'E' || ctrvowel = ctrvowel++ B
alpha == 'I' ||
alpha == 'O' || Y
alpha == 'U')
C
else if (alpha >= 'A' ctrvowel = ctrvowel++ B
&& alpha <= 'Z')
Y
Output
Invalid
ctr = ctr++ B
Y
for A
ctr <= 10
Output
ctrvowel, Stop
ctrcons
2.) C++ Program