Category: C++

Write the definition of a function named averager that receives a double parameter and returns– as a double — the average value that it has been passed so far.

Write the definition of a function named averager that receives a double parameter and returns– as a double — the average value that it has been passed so far.

LANGUAGE: C++ CHALLENGE: Write the definition of a function named averager that receives a double parameter and returns– as a double — the average value that it has been passed so far. So, if you make these calls to average, averager(5.0), averager(15.0), averager(4,3), the values returned will be (respectively): 5.0, 10.0, 8.1.

Read More

Rewrite the function body of this function so that instead of using iterating through the elements of the parallel arrays

Rewrite the function body of this function so that instead of using iterating through the elements of the parallel arrays

LANGUAGE: C++ CHALLENGE: consider the testPIN function used in Program 7-21. For convenience, we have reproduced the code for you below. Rewrite the function body of this function so that instead of using iterating through the elements of the parallel arrays, it returns true or false by calling countMatches the function defined in the previous […]

Read More

Write the implementation (.cpp file) of the  Averager class of the previous exercise. The full specification of the class is: An data member named  sum of type integer.

Write the implementation (.cpp file) of the  Averager class of the previous exercise. The full specification of the class is: An data member named  sum of type integer.

LANGUAGE: C++ CHALLENGE: Write the implementation (.cpp file) of the Averager class of the previous exercise. The full specification of the class is: An data member named  sum of type integer. An data member named  count of type integer. A constructor with no parameters. The constructor initializes the data members sum and the data member  count […]

Read More

Write the implementation (.cpp file) of the  Accumulator class of the previous exercise. The full specification of the class is

Write the implementation (.cpp file) of the  Accumulator class of the previous exercise. The full specification of the class is

LANGUAGE: C++ CHALLENGE: Write the implementation (.cpp file) of the  Accumulator class of the previous exercise. The full specification of the class is: An data member named  sum of type integer. A constructor that accepts no parameters. The constructor initializes the data member sum to 0. A function named getSum that accepts no parameters and returns an […]

Read More

Write the implementation (.cpp file) of the Counter class of the previous exercise.

Write the implementation (.cpp file) of the Counter class of the previous exercise.

LANGUAGE: C++ CHALLENGE: Write the implementation (.cpp file) of the Counter class of the previous exercise. The full specification of the class is: A data member  counter of type int. An data member named limit of type int. A static  int data member named  nCounters which is initialized to 0. A constructor that takes two  int arguments and assigns the […]

Read More

Creating objects of the Currency class require a name (string), a currency symbol (string) and the number of decimal places (integer) usually associated with the currency (in that order).

Creating objects of the Currency class require a name (string), a currency symbol (string) and the number of decimal places (integer) usually associated with the currency (in that order).

LANGUAGE: C++ CHALLENGE: Creating objects of the Currency class require a name (string), a currency symbol (string) and the number of decimal places (integer) usually associated with the currency (in that order). Creating objects of the Money class require a Currency object, and the actual amount (integer) (in that order). Define an object of type […]

Read More

Given three variables, k, m, n, of type int that have already been declared and initialized, write some code that prints each of them left-justified in a 9-position field on the same line.

Given three variables, k, m, n, of type int that have already been declared and initialized, write some code that prints each of them left-justified in a 9-position field on the same line.

LANGUAGE: C++ CHALLENGE: Given three variables, k, m, n, of type int that have already been declared and initialized, write some code that prints each of them left-justified in a 9-position field on the same line. For example, if their values were 27, 987654321, -4321, the output would be: |27xxxxxxx987654321-4321xxxx NOTE: The vertical bar,  | […]

Read More

Declare a structure whose tag name is Server and that contains the following fields: manufacturer, a string, model and serialnum, both also strings, year, an int, clockSpeed, a double, cores, an int, ram, an int and finally storage an int.

Declare a structure whose tag name is Server and that contains the following fields: manufacturer, a string, model and serialnum, both also strings, year, an int, clockSpeed, a double, cores, an int, ram, an int and finally storage an int.

LANGUAGE: C++ CHALLENGE: Declare a structure whose tag name is Server and that contains the following fields: manufacturer, a string, model and serialnum, both also strings, year, an int, clockSpeed, a double, cores, an int, ram, an int and finally storage an int.

Read More