Question: Programming Exam # 2 ( released 5 minutes before lab on Wednesday, December 4 , 2 0 2 4 ) READ THESE NOTES BEFORE YOU

Programming Exam #2(released 5 minutes before lab on Wednesday, December 4,2024)
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 100 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 50th 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 0.0
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 50 points possible as follows:
15 if your code passes the compile test which will attempt to create an object of Stats, no file I/O
10 if your code passes the fileI/O test which will attempt to create an object of Stats from a text file
5 if your count and capacity methods work as expected
8 if your avgAll works as expected
6 if your avgEven and avgOdd work as expected
3 if your avgFib works as expected for up to the 10th Fibonacci number, which is 144
3 if your avgFib works as expected for up to the 48th Fibonacci number, which is 12586269025
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 (1020). 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 2 files (stats.cpp, 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 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 Programming Questions!