Question: Programming Exam # 2 ( released 5 minutes before lab on Wednesday, December 4 , 2 0 2 4 ) READ THESE NOTES BEFORE YOU
Programming Exam #released minutes before lab on Wednesday, December
READ THESE NOTES BEFORE YOU BEGIN:
READ ALL INSTRUCTIONS BEFORE YOU BEGIN.
YOU MUST NAME YOUR FILES stats.cpp stats.h case sensitive as always
PROBLEM STATEMENT
You must solve this problem by yourself, however you may google to find C help as needed. YOU MAY NOT INCLUDE CODE THAT YOU FIND ONLINE. Submit only code that you have written yourself.
Your grade will be based upon the number of unit tests that you pass. Nothing else. Documentation and code quality are not part of the grade.
You will build a class that is capable of reading in a text file of integers, storing them in a vector, providing various statistical results from these integers.
Create a class called Stats which contains the following:
private: a vector
private: a string for the name of the file
you may have any other private variables you need
constructor a null constructor that creates an empty vector with a capacity of and empty filename an empty string is
constructor takes the name of a file located in the current directory which contains integers one per line; load the integers into the vector and store the name of the file
method capacity returns capacity of the vector
method count which returns the count of integers in the vector
method countEven which returns the count of integers that are even
method countOdd which returns the count of integers that are odd
method countFib which returns the count of the integers that are in the Fibonacci Sequence up to the th number of the sequence
method avgAll which returns the average of all the integers as a floating point value
method avgEven which returns the average of all the integers that are even as a floating point value
method avgOdd which returns the average of all the integers that are odd as a floating point value
method avgFib which returns the average of all the integers that are in the Fibonacci Sequence as a floating point value
note: if there are no numbers for a given average, return the float value of
Do NOT submit a main program, just the Stats class files cpp and h
Be sure to handle reading from the text file properly regardless of EOL on the file. Also handle the potential of an extra line at EOF.
GRADING here is how the tests will correlate to your grade
there will be points possible as follows:
if your code passes the compile test which will attempt to create an object of Stats, no file IO
if your code passes the fileIO test which will attempt to create an object of Stats from a text file
if your count and capacity methods work as expected
if your avgAll works as expected
if your avgEven and avgOdd work as expected
if your avgFib works as expected for up to the th Fibonacci number, which is
if your avgFib works as expected for up to the th Fibonacci number, which is
Here are some sample test data files for you to test with. test data zip fileDownload test data zip file
SUBMISSION INSTRUCTIONS
Name your file stats.cpp stats.h Submit your solution to Gradescope It is your responsibility to make sure what you submit compiles and works correctly per the test data provided in Gradescope.
BE SURE IT COMPILES CORRECTLY UNDER LINUX BEFORE YOU SUBMIT.
IF YOU SUBMIT AFTER YOUR LAB SECTION ENDS YOU RISK RECEIVING A GRADE OF ZERO. Don't be late.
You should only submit files statscpp stats.h
Lastly, your files should NOT contain a main function, as this could crash the autograder. So when you are testing it you can use a main function, but before you submit, you should take your main function out of your code.
GRADESCOPE SUBMISSION LINK
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
