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
____ contain instructions for the OS for hardware devices, such as the keyboard, mouse, and video card, and are stored in the sy
AnnyKZ [126]

The Motherboard contains instructions for the OS for hardware devices, such as the keyboard, mouse, and video card, and are stored in the systemroot\Windows\System32\Drivers folder.

Learned this in middle school, your welcome ;)

3 0
3 years ago
What is a symbol such as a heavy dot or another character that precedes a text in a power point
Fantom [35]

Answer:

<em>I </em><em>think </em><em>the </em><em>answer </em><em>is </em><em>a </em><em>bullet.</em>

<em>Hope </em><em>this </em><em>helps</em>

4 0
1 year ago
Variables defined inside a member function of a class have: Block scope. Class or block scope, depending on whether the binary s
Snowcat [4.5K]

Answer:

The answer is "Block scope".

Explanation:

In the programming, the scope is a code, in which it provides the variable ability to exist and not be retrieved beyond variable. In this, the variables could be defined in 3 locations, that can be described as follows:

  • Inside a method or the block, which is also known as a local variable.
  • Outside of the method scope, which is also known as a global variable.
  • Defining parameters for functions known as formal parameters.
8 0
3 years ago
What information can be determined from a device's MAC address?​
rewona [7]

Answer:

I believe it is the NIC manufacturer and the serial number of the NIC

Explanation:

5 0
3 years ago
12While trying to solve a network issue, a technician made multiple changes to the current router configuration file. The change
AfilCa [17]

Answer:

Issue the reload command without saving the running configuration.

Explanation:

5 0
3 years ago
Other questions:
  • A url consists of a ____, a domain name, sometimes the path to a specific web page or location in a web page, and the web page n
    11·1 answer
  • a reviewer is required to enter a reason in the comments field only when a candidate is recommended to be hired. which action ca
    8·1 answer
  • SOMEONE PLZZ HELP ME ASAP!!
    15·2 answers
  • How can you keep your files organized on your computer?
    13·2 answers
  • What are some characteristics of filtering junk email in Outlook 2016? Check all that apply.
    9·2 answers
  • An administrator has noticed that GPO containing new update settings has not yet applied to one of the computers on the network.
    5·1 answer
  • Web résumés are posted to the Internet in HTML format.<br> true or false
    9·2 answers
  • If you face an investigation where dangerous substances might be around, you may need to obtain which of the following?
    13·2 answers
  • What is the missing line of code?
    10·2 answers
  • 8
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!