ive just started c++, n im not really good, even with the simple programs, couls someone help me with this?
thanx
Question 3 (10 marks)
Concepts:
• Static local variables
Implement a function to track various details regarding a list of exam results. Download
and extract prac6-q3.tar.gz and read the code in main.cpp to understand the simple control
flow. You are required to define the prototypes declared in marks.h. Do so in a file called
marks.cpp. Again write a makefile to automate the build. Your executable must be called
mark-stats in order for Fitchfork to evaluate your program.
Implement the functions according to the following specifications:
3.1 getMark() is to prompt the user to enter a mark as follows: (3)
>> Enter a mark (-1 to quit): <user input>
Return any input2 entered except if it is a mark of over 100.00. In such a situation
terminate as below:
>> Enter a mark (-1 to quit): 109
Invalid input! System aborting...
3.2 trackMarks() is to provide a running list of mark details by making use of static local (7)
variables. Each time the function is called, calculate and display the following details:
>> Enter a mark (-1 to quit): 67
***************************************
** Mark Details
***************************************
** Average: 67.00
** Highest: 67.00
** Lowest: 67.00
** Total Sum: 67.00
2
Technically speaking, any negative number will act as a sentinel in main.cpp, even though we only prompt
for -1. In this case it is a triviality, but it is important to be aware of such seemingly trivial details.
Page 7 of 9
COS 130/COS 132 Practical 6
** Sum of Squares: 4489.00
** Total Entries: 1
** First Entry: 67.00
** Last Entry: 67.00
***************************************
Each time the function is called, your calculations must update the display accordingly.
For example, after the tenth call for an arbitrary set of inputs the display could look as
follows:
***************************************
** Mark Details
***************************************
** Average: 63.00
** Highest: 90.00
** Lowest: 35.00
** Total Sum: 630.00
** Sum of Squares: 42464.00
** Total Entries: 10
** First Entry: 67.00
** Last Entry: 70.00
***************************************
Note that you need to format the output to display at 2 decimal places and ensure that
it is not in scientific notation. Also use stream manipulators to make the numbers right
justified such that they align uniformly on the decimal point.
Note that Total Sum refers to the sum of all entries while Sum of Squares refers to the
total sum of each entries’ square.
When your program is complete, compress marks.h, marks.cpp, main.cpp, input and
Makefile into a tarball and upload under Fitchfork assignment prac6-q3.
ntombazana 0 Newbie Poster
emilo35 3 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.