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
Synchronization barriers are a common paradigm in many parallel applications.
Bas_tet [7]

Answer:

I am not sure on this one I am guessing it is True

Explanation:

3 0
3 years ago
Johnny is a member of the hacking group Orpheus1. He is currently working on breaking into the Department of Defense's front end
sweet [91]

Answer:

RainbowTables

Explanation:

RainbowTables is the best option when the cracker has limited time.

6 0
3 years ago
How many 16-byte cache blocks are needed to store all 64-bit matrix elements being referenced using matlab's matrix storage?
kenny6666 [7]

answer:

4 16-byte cache blocks are needed.

3 0
3 years ago
What is true about using the reserved word super?
Kitty [74]

Answer:

It can only be used in superclasses

Explanation:

In computer language, a reserved word is a word that cannot be used as an identifier, such as the name of a variable, function, or label, it is "reserved from use".

If your method overrides one of its superclass's methods, you can invoke the overridden method through the use of the keyword super, it can also be used to refer to a hidden field.

We can conclude that the correct answer is "It can only be used in superclasses" because, in a subclass’ constructor, we can call the superclass’ constructor with the keyword super instead of the superclass’ (constructor’s) name.

I hope you find this information useful and interesting! Good luck!

5 0
3 years ago
Create the logic for a program that calculates and displays the amount of money you would have if you invested $5000 at 2 percen
avanturin [10]

Answer:

# main function is defined

# the calculateAmount is called here

def main():

   print("The new amount is: ", calculateAmount(), sep="")

   

# calculateAmount function that calculate the interest

def calculateAmount():

   # the value of principal is p

   p = 5000

   # the value of rate is r

   r= 2

   # the time is t

   t = 1

   # the formula for finding interest

   interest = (p * r * t) / 100

   # the new amount is calculated

   amount = p + interest

   # the amount is returned

   return amount

# a call that make main function begin execution

if __name__ == "__main__":

   main()

Explanation:

The program is written in Python and it is well commented. A screenshot is attached showing program output

8 0
3 years ago
Read 2 more answers
Other questions:
  • If the wrong server edition is installed, what command can be used to change to a different edition?​
    5·1 answer
  • Which key removes all data from an active cell with one click? A. Esc B. Delete C. Tab D. F2
    9·2 answers
  • Mation about which osi layers of connected cisco devices can be verified with the show cdp neighbors comm
    15·1 answer
  • Universal Containers needs the ability to generate contract documents. All the data required for a contract resides in a custom
    6·1 answer
  • Two types of formulas in Excel, what are they? A. Complex and simple, B. General and currency, C. Logical and Boolean, D. Trig a
    15·1 answer
  • a. Daily Life Magazine wants an analysis of the demographic characteristics of its readers. The marketing department has collect
    13·1 answer
  • 1. Which sentence best expresses the main idea
    12·1 answer
  • Write the function evens which takes in a queue by reference and changes it to only contain the even elements. That is, if the q
    6·1 answer
  • What's exactly the difference between "Library" and "Framework" ? ​
    7·1 answer
  • What is the accurate description
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!