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
In Florida no fault insurance is optional for owners of a vehicle
Elena-2011 [213]
It is false, Its obligatory. 
7 0
3 years ago
Please explain the following joke: “There are 10 types of people in the world: those who understand binary and those who don’t.”
garik1379 [7]

It means that there are people  who understand binary and those that do not understand it. That is, binary is said to be the way that computers are known to express numbers.

<h3>What is the joke about?</h3>

This is known to be a popular  joke that is often  used by people who are known to be great savvy in the field of mathematics.

The joke is known to be one that makes the point that a person is implying that the phrase is about those who only understands the decimal system, and thus relies on numbers in groups of 10.

The binary system is one that relies on numbers that are known to be  in groups of 2.

Therefore, If the speaker of the above phrase is one who is able to understand binary, that person  would  be able to say that that the phrase  is correctly written as  "there are 2 types of people that understand binary".

Learn more about binary from

brainly.com/question/21475482

#SPJ1

4 0
2 years ago
2. Trace through the following loop and show the values for A, B &amp; C.
Butoxors [25]

At the beginning, we have

A = 4, B = 3, C = 0

Although you didn't specify the programming language, usually 0 means false, so we never enter the first loop, because "while C" is never true.

We enter the second loop because B is different from A, so we decrease C by 1, and we have

A = 4, B = 3, C = -1

and we assign B = B-C, so now B becomes 3-(-1)=3+1=4. Now B=A and we exit the second loop, and we have

A = 4, B = 4, C = -1

4 0
3 years ago
Need help with this is photography :)
mestny [16]

Answer:

UV filter, This filter blocks UV light and removes the blue cast from images taken in very bright sunny conditions. ... With old film cameras it was often necessary to use a UV filter because film is extremely sensitive to UV light.

8 0
3 years ago
Select all that apply. Two physical things you can do to demonstrate you are paying attention to a speaker are _____ and _____.
omeli [17]
B and d ............
7 0
3 years ago
Read 2 more answers
Other questions:
  • An example of hardware is a _____. a)word processor b)database c)motherboard d)internet
    15·2 answers
  • Type the correct answer in the box. Spell all words correctly.
    12·1 answer
  • Eight houses represented as cells are arranged in a straight line java int state []
    14·1 answer
  • What are the factors affecting the purchasing decision for dbms software?
    7·2 answers
  • Which of the following statements about functional programming languages is incorrect?A) In pure functional programming, there a
    5·1 answer
  • What are some effective methods for scrolling? Check all that apply.
    6·1 answer
  • A histogram titled Greeting card sales has date on the x-axis and cards (millions) on the y-axis. January is 1 card, February: 1
    12·2 answers
  • Seneca has just applied conditional formatting and realizes that she has made a mistake. Which action should she take to fix the
    12·2 answers
  • A _________ attack is an attack on a computer system or network that causes a loss of service to users.
    15·1 answer
  • Identify the type of software that should be in main memory in order to use the keyboard? *
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!