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
Which thematic group is involved in the transmission and generation of electrical power?
MariettaO [177]

The thematic group involved in the transmission and generation of electrical power is the energy system. Thus, Option D is the correct answer.

<h3>What do you mean by thematic groups?</h3>

Thematic groups refers to groups that are made up of individuals who focus on the same theme or idea. Thematic Group specializes in the improvement of a selected talent or attitude so as for the group contributors to have the ability to finish a particular activity.

Thus, The thematic group involved in the transmission and generation of electrical power is the energy system. Option D is the correct answer.

Learn more about thematic groups:

brainly.com/question/17157087

#SPJ1

3 0
2 years ago
True/False: Before a computer can execute a program written in a high level language, such as C , it must be translated into obj
Alekssandra [29.7K]

Answer:

True

Explanation:

5 0
2 years ago
_____ is(are) a written description of a computer program’s functions.
xeze [42]
Algorithm is a written description of a computer program's functions.
Please mark me as brainliest. Thanks!!
3 0
2 years ago
A program in which students learn a specific skill for a particular job is called a
Ne4ueva [31]
A certification program.
7 0
3 years ago
Read 2 more answers
This the code from the last post I did
Andrew [12]

import java.util.Scanner;

public class JavaApplication86 {

   

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       int x = 0, c = 0, sum = 0;

       while (true){

           x = scan.nextInt();

           System.out.println("You entered: "+x);

           if (x == -1){

               break;

           }

           sum += x;

           c++;

       }

       System.out.println("The sum is "+sum);

       System.out.println("You entered "+c +" numbers");

   }

   

}

This works for me. Instead of subtracting one from c and adding one to sum, I used an if statement to break away from the while loop if the entered number is -1.

3 0
3 years ago
Other questions:
  • If someone receives a shock, or a piece of equipment is throwing sparks or arcing you should try to pull them away from the sour
    7·1 answer
  • Professor Zak allows students to drop the four lowest scores on the ten 100 point quizzes she gives during the semester. Design
    13·1 answer
  • Ned and Mary Ann are saving their files to a CD. When prompted, Ned will click on Burn file to disk, indicate the recording spee
    15·1 answer
  • To make a drop shadow larger what should you change about the drop shadow in gimp
    12·1 answer
  • What is the name given to a collection of related fields such as ID number,name and address?
    12·1 answer
  • True/False
    15·1 answer
  • Name two commercial tools that can make a forensic sector-by-sector duplicate of a drive to a larger drive.
    10·1 answer
  • PLSSSSS HELPP!! Tropical rainforests are home to many kinds of birds, including parrots, toucans and eagles. Each different spec
    9·2 answers
  • How have these advances in-home technology changed the role of technicians in our society?
    10·1 answer
  • To enable grammar correction in powerpoint, you must first enable office ____ services.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!