1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Margaret [11]
3 years ago
6

Given a vector of students, the function FinalAvg is supposed to return the average final exam score across all the students in

the vector; if the vector is empty, the function is supposed to return 0.0. Write a test case using the Catch framework to test this function. You can assume that the Student class exists as presented the first day of class, any other inputs and object construction should be part of your test case.
Computers and Technology
1 answer:
alexandr1967 [171]3 years ago
8 0

Answer:

The C++ code is given below with appropriate comments

Explanation:

#define CATCH_CONFIG_MAIN //This tells Catch to provide a main()

#include"catch.hpp" //Header for Catch Framework

double FinalAvg( vector <int> students) // Function to calculate average.

{

double sum =0;

int i;

for( i=0;i<v.size();i++) sum+= v[i];

return v.empty() ? 0.0 : (double(sum)/ v.size());

}

vector<int> func(int argvq[ ]) // This function is made because we can not provide vector in command line argument that's why we used array which is then conerted into vector.

{

vector<int> v;

int j;

int l= sizeof(argvq)/sizeof(argvq[0]);

for(j=0;j<l;j++)

v.push_back(argq[j]);

return v;

}

TEST_CASE(" Final Average marks are computed","[func]") // TEST_ CASE macro to take one or more arguments

{

REQUIRE( func(9,5,-7) == 7); // We write our individual test assertions using the REQUIRE macro.

REQUIRE(func(2,4,6,-2) ==4);

}

Explanation Using different IDE:

#include<bits/stdc++.h>

using namespace std;

double FinalAvg(vector<int> students)

{

double sum=0;

for(int i=0;i<v.size();i++) sum+= v[i];

return v.empty() ? 0.0 : (double(sum)/v.size());

}

int main()

{

vector<int> v;

int i;

while(cin>>i&&i>0) v.push_back(i);

cout<<Final Avg(v);

return 0;

}

You might be interested in
What does this say in morse code?
Furkat [3]

Answer:

That it is time for lunch?

Explanation:

4 0
3 years ago
Read 2 more answers
What are the differences between packet and circuit switching? Which is more prevalent today?
Juliette [100K]

Answer: The difference present between the packet switching and circuit switching are as follows:-

  • Packet switching i the switching in which the data packet travels through the connectionless path whereas connection oriented routes are present for circuit switching
  • Network layer uses the feature of packet switching while physical layer uses circuit switching technique
  • Data transferring is mostly preferred through packet switching and voice communication takes place through the circuit switching.
  • Packet switching is considered flexible as no already established connection is present for switching but the connection in circuit switching are already defined which makes it less flexible.

Among the packet switching and circuit switching , packet switching is preferred for the communication through the data packets because they have  flexibility and affordability.It can establish numerous connection for switching and this make it efficient.

4 0
3 years ago
_________ local variables retain their value between function calls.
SOVA2 [1]

Answer: static

Explanation:

variables when declared static gets called statically meaning whenever a function call is made it get stored and it is not required to get the variable again when the function is again called. There scope is beyond the function block

4 0
2 years ago
Which daemon manages the physical memory by moving process from physical memory to swap space when more physical memory is neede
Anastasy [175]

Answer:

Swap daemon

Explanation:

Swap daemon manages the physical memory by moving process from physical memory to swap space when more physical memory is needed. The main function of the swap daemon is to monitor processes running on a computer to determine whether or not it requires to be swapped.

The physical memory of a computer system is known as random access memory (RAM).

A random access memory (RAM) can be defined as the internal hardware memory which allows data to be read and written (changed) in a computer.Basically, a random access memory (RAM) is used for temporarily storing data such as software programs, operating system (OS),machine code and working data (data in current use) so that they are easily and rapidly accessible to the central processing unit (CPU).

Additionally, RAM is a volatile memory because any data stored in it would be lost or erased once the computer is turned off. Thus, it can only retain data while the computer is turned on and as such is considered to be a short-term memory.

There are two (2) main types of random access memory (RAM) and these are;

1. Static Random Access Memory (SRAM).

2. Dynamic Random Access Memory (DRAM).

6 0
3 years ago
Anyone have good websites to cure boredom
Sav [38]

Answer:

cool math if its not blocked

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Data is: a. Information endowed with relevance and purpose b. Set of specific objective facts or observations c. Some informatio
    10·1 answer
  • Multiple systems try to send data at the same time. The electrical impulses sent across the cable interfere with each other. Wha
    15·1 answer
  • What will be displayed after the following code is executed? def pass_it(x, y): z = x*y result = get_result(z) return(result) de
    13·1 answer
  • Predict how digital video will be viewed in the future. Step into the year 2028. How are people viewing digital video? Or have w
    13·2 answers
  • In what year did the manager and team depicted in the blockbuster film "Moneyball
    9·1 answer
  • What is the primary responsibility of the federal reserve bank??
    11·1 answer
  • Which of these organs is not found in the excretory system
    7·2 answers
  • The amount of time taken by each of 10 students in a class to complete an exam is an example of what type of data? a. Cannot be
    15·1 answer
  • When you press the ____ key without entering any text after the automatic bullet character, Word turns off the automatic bullets
    11·1 answer
  • Why can't I register for Brainly?? I've been trying for months, too! I've noticed this question has been asked so many times, bu
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!