Assignment 3

$24.99 $18.99

Problem 1 [2 pts] Exercise 11.6: Using the following de nitions of MAX JUDGES and scores as a starting point. const int MAX JUDGES = 100; double scores[MAX JUDGES]; Write a program that reads in gymnastics scores between 0 and 10 from a set of judges and then computes the average of the scores after…

Rate this product

You’ll get a: zip file solution

 

Categorys:
Tags:

Description

Rate this product

Problem 1 [2 pts]

Exercise 11.6:

Using the following de nitions of MAX JUDGES and scores as a starting point.

const int MAX JUDGES = 100;

double scores[MAX JUDGES];

Write a program that reads in gymnastics scores between 0 and 10 from a set of judges and then computes the average of the scores after eliminating both the highest and lowest scores from consideration. Your program should accept input values until the maximum number of judges is reached or the user enters a blank line. A sample run of this program might look like this:

Requirments:

Please nish sumArray, ndLargest and ndSmallest functions in the le Gymnastics-Judge.cpp according to the le GymnasticsJudge.h.

Problem 2 [3 pts]

(a) Exercise 12.4:

Design and implement a class called IntArray that implements the following methods:

A constructor IntArray(n) that creates an IntArray object with n elements, each of which is initialized to 0.

A destructor that frees any heap storage allocated by the IntArray.

A method size() that returns the number of elements in the IntArray.

A method get(k) that returns the element at position k. If k is outside the vector bounds, get should call error with an appropriate message.

A method put(k, value) that assigns value to the element at position k. As with get, the put method should call error if k is out of bounds.

Requirments:

Please nish constructor, destructor, size, get and put functions in the le intarray.cpp according to the le intarray.h.

(b) Exercise 12.5:

You can make the IntArray class from the preceding exercise look a little more like traditional arrays by overriding the bracket-selection operator, which has the following prototype:

int & operator[](int k);

Like the get and put methods, your implementation of operator[] should check to make sure that the index k is valid. If it is, the operator[] method should return the element by reference so that clients can assign a new value to a selection expression.

Requirments:

Please nish operator[] function in the le intarray.cpp according to the le intarray.h

(c) Exercise 12.6:

Implement deep copying for the IntArray class from Problem 2(a) and (b).

Requirments:

Please nish copy constructor and assignment operator in the le intarray.cpp according to the le intarray.h

Requirements for Assignment

We have provided a project named as AS3 ID.pro. Firstly, please replace the ID with your student ID in both .pro le and the project folder name. (e.g. if your student ID is 123456, hereby the le should be named as AS3 123456),

You should nish all .cpp les except the Assignment3.cpp according to the problem require-ments. You are not allowed to modify any .h les. Finally, pack your whole project les into a single .zip le, and submit the .zip le via BB system.

Please note that, the teaching assistant may ask you to explain the meaning of your program, to ensure that the codes are indeed written by yourself. Please also note that we may check whether your program is too similar to your fellow students’ code using BB.

Please refer to the BB system for the assignment deadline. For each day of late submission, you will obtain late penalty in the assignment marks.

Reminder: Please switch your input language to English before interacting in Stanford console.

Or, you will get no response.

Assignment 3
$24.99 $18.99