Question: Do the following in visual studio code: Problem 1 Deliverable: problem 1 . cpp Purpose: Create a program that will accept characters input from the
Do the following in visual studio code:
Problem
Deliverable: problemcpp
Purpose: Create a program that will accept characters input from the standard input device
using cin The program should stop accepting input when a period, question mark, or
exclamation point is input or The program will output the number of alphabetic characters
az Az and the number of digits that were input in the form Input sentence contains
number alphabetic charactercharacters and number digitdigits Note: the words character and
digit should be singular or plural as appropriate.
Specifications:
Do not prompt for the program input.
Assume the input sentence will be from the standard input device using cin
Produce all output to the standard output device using cout
Sample input output pairs:
Input: Count characters in this sentence.
Output: Input sentence contains alphabetic characters and digits.
Input: Hey, do you count letters?
Output: Input sentence contains alphabetic characters and digits.
Input: more win!
Output: Input sentence contains alphabetic characters and digit.
Initial Testing:
A makefile, checkit.cpp source file, and sample input and output files have been provided to run initial tests on your program. To run the tests provided, create a directory containing only your problemcpp file and the files extracted from the attached problemtests.zip.
makefile for problem :
#
# $@ target
# $ first prerequisite
# $ all prerequisites
flags stdcWall I
problemo : problemcpp
g $flagsc $
problem : problemo
g $flags $o $@
checkit : checkit.cpp
g $flags $o $@
problemtest : checkit problem problemsampleinputtxt
problem problemsampleinputtxt problemstudentoutputtxt
checkit
problemtest : checkit problem problemsampleinputtxt
problem problemsampleinputtxt problemstudentoutputtxt
checkit
problemtest : checkit problem problemsampleinputtxt
problem problemsampleinputtxt problemstudentoutputtxt
checkit
clean :
rm o checkit problem problemstudentoutputtxt
Checkit.cpp:
#include
using std::ifstream;
#include
using std::cout;
using std::endl;
using std::cin;
#include
using std::string;
#include
int mainint argc, char argv
executable must be called with a test number
if argc argv argv
cout "Invalid test" endl;
return ;
convert the character to an integer
int which argv;
string correct "problemexpectedoutputtxt
"problemexpectedoutputtxt
"problemexpectedoutputtxt;
string student "problemstudentoutputtxt
"problemstudentoutputtxt
"problemstudentoutputtxt;
ifstream correctfilecorrectwhich;
ifstream studentfilestudentwhich;
bool match true;
char correctchar, stuchar;
int i ;
cout "Your output:" endl;
correctchar correctfile.get;
stuchar studentfile.get;
while correctfile.good && studentfile.good && match
match correctchar stuchar;
cout stuchar;
if match
cout this character
isspacestuchara whitespace character :
"should be correctchar
correctchar a space :
correctchar ta tab :
correctchar
a newline : endl;
i;
correctchar correctfile.get;
stuchar studentfile.get;
cout
;
if match
cout "output error at character i
Open studentwhich to view your full output and
"compare it to the expected ouput in correctwhich endl;
else if correctfile.eof
cout "student file ended too soon make sure your last output statement
"ends with endl
Open studentwhich to view your
"full output and compare it to the expected ouput in
correctwhich endl;
else if studentfile.eof
cout "extra output in student file"
Open studentwhich
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
