Question
Write code in c++ please. I don't need an explanation. Just program1.cc checkit.cc: #include using std::ifstream; #include using std::cout; using std::endl; using std::cin; #include using
Write code in c++ please. I don't need an explanation. Just program1.cc
checkit.cc:
#includeusing 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] '2' ) { cout Makefile:
program1 : program1.cc
g++ -Wall -std=c++17 program1.cc -o program1
checkit : checkit.cc
g++ -Wall -std=c++17 checkit.cc -o checkit
test1 : program1 checkit test1-input.txt correct-test1.txt
./program1 student-test1.txt
./checkit 0
test2 : program1 checkit test2-input.txt correct-test2.txt
./program1 student-test2.txt
./checkit 1
test3 : program1 checkit test3-input.txt correct-test3.txt
./program1 student-test3.txt
./checkit 2
clean :
rm student* checkit program1
correct-test1.txt:
3 + 4 > -1 - Correct 12 % 7 0 - Incorrect 1 of 3 = 33.33%correct-test2.txt:
Unrecognized relational operator ~ 3 * 4 > 12 - Incorrect Unrecognized arithmetic operator ^ 7 - 12correct-test3.txt:
Unrecognized arithmetic operator | Unrecognized relational operator ? 0 of 0 = 0.00%test1-input.txt:
3 + 4 > -1 c 12 % 7 0 qtest2-input.txt:
1 + 2 ~ 3 c 3 * 4 > 12 c 8 ^ 10 > 0 c 7 - 12test3-input.txt:
1 | 2 ? 3 qExample Output:
rogram Purpose - Check relational expressions for correctness. The program should accept relational expressions input from the standard input device (using cin) in the format integer arithmetic-operator integer less-than-or-greater-than-symbol integer Assume that the user will input expressions in this format, entering only integer values for the numbers, and single characters for the arithmetic and relational operators. If the arithmetic operator entered is not a valid C++ arithmetic operator ( +,, *, /, \%) the program should output "Unrecognized arithmetic operator" followed by the character input where an arithmetic operator was expected (see examples below). If the relational operator entered is not , the program should output "Unrecognized relational operator" followed by the character input where a relational operator was expected (see examples below). The program should determine if the expression entered is a true statement. If the expression is a true statement, output the relational expression followed by " - Correct". If the expression is a false statement, output the relational expression followed by " - Incorrect". Example input/output pairs Input: 3+4>1 Output: 3+4>1 - Correct Input: 12%728 Output: Unrecognized arithmetic operator Input: 37 * 3 Output: Unrecognized relational operator * After each relational expression entered, the user will input ' c ' to continue (to enter another relational expression) or ' q ' to quit. The program should read each input relational expression and produce the corresponding output as described above until the user enters q. After the user enters q, the program should output a summary of the results in the format: number-correct of total-number-of-expressions = percent-correct\% The percent correct should display with two places following the decimal. Specifications - All output should be directed to the standard output device using cout. - All input should be accepted from the standard input device using cin. - Do not prompt for input. - All of your source code for the program must be contained in a single file named program1.cc - You will submit program1.cc to the assignment in Blackboard. - Programs must compile and run on a computer of the instructor's choosing in the Linux lab (see your course syllabus for additional details). - Be sure to review the program expectations section of the course syllabus. Testing Text files containing sample input and the corresponding expected output are attached to the program assignment. A makefile has been included to run your program with the sample input and compare the results to the expected output. In order to use the makefile, ensure that your program1.cc and all of the files attached to the assignment (checkit.cc, correct-test1.txt, correct-test2.txt, correct-test3.txt, test1-input.txt, test2-input.txt, test3-input.txt) are in the same directory. The commands to run the tests are given below: make test1 make test2 make test3 Example input/output pairs Input: 3+4>1 Output: 3+4>1 - Correct Input: 12%728 Output: Unrecognized arithmetic operator Input: 373 Output: Unrecognized relational operator *
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started