Data files will be provided to test theseranging from 3K to 260K. i.e. leaf.dat
ID: 3610970 • Letter: D
Question
Data files will be provided to test theseranging from 3K to 260K. i.e. leaf.dat (leaf and stem datafile) Part 1 Write a program to accept from the user oneline of text. Now count and output the number of uppercase lettersin that line. Part 2 Modify your program in Part 1 to read from yourtext file in place of the user input. Output your results to thescreen. Part 3 Modify your program in Part 2 to count andoutput to the screen the number of times your initials (first andlast names only and uppercase only) occur in your textfile. Part 4 Write a program to accept from the user oneline of text. Now count and output the number of upper- andlower-case vowels in that line. Hint: a switch statementmakes this program relatively ease to code. Part 5 Modify your program in Part 4 to read from yourtext file in place of the user input. Output your results to thescreen. Data files will be provided to test theseranging from 3K to 260K. i.e. leaf.dat (leaf and stem datafile) Part 1 Write a program to accept from the user oneline of text. Now count and output the number of uppercase lettersin that line. Part 2 Modify your program in Part 1 to read from yourtext file in place of the user input. Output your results to thescreen. Part 3 Modify your program in Part 2 to count andoutput to the screen the number of times your initials (first andlast names only and uppercase only) occur in your textfile. Part 4 Write a program to accept from the user oneline of text. Now count and output the number of upper- andlower-case vowels in that line. Hint: a switch statementmakes this program relatively ease to code. Part 5 Modify your program in Part 4 to read from yourtext file in place of the user input. Output your results to thescreen.Explanation / Answer
please rate -thanks part 1 #include<iostream.h>#include <string>
using namespace std;
int main()
{
int upper=0,i;
string input;
cout<<"Enter a line of text: ";
getline(cin,input);
for(i=0;i<input.length();i++)
if(input[i]>='A'&&input[i]<='Z')
upper++;
cout<<"Upper case letters: "<<upper<<endl;
system("pause");
return 0;
}
part 4 #include<iostream.h>
#include <string>
using namespace std;
int main()
{
int upper=0,i,uvowel=0,lvowel=0;
string input;
cout<<"Enter a line of text: ";
getline(cin,input);
for(i=0;i<input.length();i++)
{if(input[i]>='A'&&input[i]<='Z')
upper++;
switch(input[i])
{case 'A':
case 'E':
case 'I':
case 'O':
case 'U': uvowel++;
break;
case 'a':
case 'e':
case 'i':
case 'o':
case 'u': lvowel++;
break;
}
}
cout<<"Upper case letters: "<<upper<<endl;
cout<<"Upper case vowels: "<<uvowel<<endl;
cout<<"lower case vowels: "<<lvowel<<endl;
system("pause");
return 0;
}
part 4 #include<iostream.h>
#include <string>
using namespace std;
int main()
{
int upper=0,i,uvowel=0,lvowel=0;
string input;
cout<<"Enter a line of text: ";
getline(cin,input);
for(i=0;i<input.length();i++)
{if(input[i]>='A'&&input[i]<='Z')
upper++;
switch(input[i])
{case 'A':
case 'E':
case 'I':
case 'O':
case 'U': uvowel++;
break;
case 'a':
case 'e':
case 'i':
case 'o':
case 'u': lvowel++;
break;
}
}
cout<<"Upper case letters: "<<upper<<endl;
cout<<"Upper case vowels: "<<uvowel<<endl;
cout<<"lower case vowels: "<<lvowel<<endl;
system("pause");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.