Question: Problem 1 Deliverable: problem1.cc Test all of your code on a Linux lab computer. All source files submitted must compile and run on a Linux

Problem 1

Deliverable: problem1.cc

Test all of your code on a Linux lab computer. All source files submitted must compile and run on a Linux lab computer of the instructors choice. Submissions that do not compile on the Linux workstation will receive no compilation or execution/correctness points. 
You should submit only the following individual files to the assignment: problem1.cc 

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 (a-z A-z) and the number of digits (0-9) that were input in the form Input sentence contains number alphabetic character/characters and number digit/digits. Note: the words character and digit should be singular or plural as appropriate.

 Specifications: 

Do not prompt for the program input.

Assume that two valid integers will be input 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 29 alphabetic characters and 0 digits. Input: Hey, do you count 12 letters?

Output: Input sentence contains 20 alphabetic characters and 2 digits. Input: 1 more win!

Output: Input sentence contains 7 alphabetic characters and 1 digit. Initial Testing:

 A makefile, checkit.cc source file, and sample input and output files have been provided to run initial tests on your program. You are encouraged to create more rigorous tests. To run the tests provided, create a directory containing only your problem1.cc file and the files extracted from the attached problem1tests.zip. Then type the following commands at the command prompt: 
 make problem1test1 make problem1test2 make problem1test3 

Points: style: 1 point clean compilation: 1 point execution / correctness (passes instructor tests): 2 points

checkit.cc

#include

using std::ifstream;

#include

using std::cout;

using std::endl;

using std::cin;

#include

using std::string;

#include

int main(int argc, char *argv[]) {

// executable must be called with a test number 0-2

if ( argc != 2 || argv[1][0] '4' ) {

cout

return 1;

}

// convert the character to an integer

int which = argv[1][0] - '0';

string correct[3] = { "problem1-expected-output-1.txt",

"problem1-expected-output-2.txt",

"problem1-expected-output-3.txt" };

string student[3] = { "problem1-student-output-1.txt",

"problem1-student-output-2.txt",

"problem1-student-output-3.txt" };

ifstream correctfile(correct[which]);

ifstream studentfile(student[which]);

bool match = true;

char correctchar, stuchar;

int i = 0;

cout

correctchar = correctfile.get();

stuchar = studentfile.get();

while ( correctfile.good() && studentfile.good() && match ) {

match = correctchar == stuchar;

cout

if ( !match )

cout

(correctchar == '\t' ? "(a tab)" :

(correctchar == ' ' ? "(a newline)" : "")))

++i;

correctchar = correctfile.get();

stuchar = studentfile.get();

}

cout

if ( !match )

cout

else if ( !correctfile.eof() )

cout

else if ( !studentfile.eof() )

cout

else

cout

return 0;

}

makefile

# makefile for problem 1

#

# $@ target

# $

# $^ all prerequisites

flags = -std=c++17 -Wall -I .

problem1.o : problem1.cc

g++ $(flags) -c $

problem1 : problem1.o

g++ $(flags) $

checkit : checkit.cc

g++ $(flags) $^ -o $@

problem1test1 : checkit problem1 problem1-sample-input-1.txt

./problem1 problem1-student-output-1.txt

./checkit 0

problem1test2 : checkit problem1 problem1-sample-input-2.txt

./problem1 problem1-student-output-2.txt

./checkit 1

problem1test3 : checkit problem1 problem1-sample-input-3.txt

./problem1 problem1-student-output-3.txt

./checkit 2

clean :

rm *.o checkit problem1 problem1-student-output-*.txt

Problem 1 Deliverable: problem1.cc Test all of your code on a Linux

problem1-expected-output-1 Input sentence contains 23 alphabetic characters and 3 digits. problem1-expected-output-2 Input sentence contains 1 alphabetic character and 3 digits. problem1-expected-output-3 Input sentence contains 49 alphabetic characters and 0 digits. problem1-sample-output-1 I intend to earn a 100 on the exam. problem1-sample-output-2 1 u 2 . problem1-sample-output-3 This sentence is on multiple lines, which is interesting, no

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!