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 order to average together values that match two different conditions in different ranges, an Excel user should use the functi
Tomtit [17]
In order to average together values that match two different conditions in different ranges, an Excel user should use the Excel Average functions.<span>To calculate average in Excel,the powerful Excel Average functions will do the work behind the scene.  </span>You use the AVERAGE function in Excel to return the average (arithmetic mean) of the specified cells. The different functions are : <span><span>Excel AVERAGE - calculate the mean of cells with numbers.  </span><span>Excel AVERAGEA - find an average of cells with any data. </span><span>Excel AVERAGEIF - average cells based on a given criterion. </span><span>Excel AVERAGEIFS - average cells that match several criteria.</span></span>
6 0
3 years ago
Write a program to calculate and return total surface area of a box using FUNCTION _END FUNCTION.​
Andrei [34K]

Answer:

def funct1():

   h=int(input("Enter height of the box"))

   w=int(input("Enter the width of the box"))

   L=int(input("Enter the length of the box"))

   surface_area=2*(h*w + h*L + w*L)

   return surface_area

a=funct1()

print(a)

Explanation:

Please check the answer section.

6 0
3 years ago
Choose the best technology device for the
Oxana [17]

Answer:

Desktop computer with 2 screens

Explanation:

All graphices designers need the most screen space possible

8 0
3 years ago
Match each term in the second column with its correct definition in the first column. Write the letter of the term on the blank
Thepotemich [5.8K]

Answer:

1. Pie chart.

2. Goal seek.

3. Relative reference cell.

4. Data marker.

5. Chart sheet.

6. What-If-Analysis.

7. Rate = \frac {Amount \; of \; increase}{Base}

8. Order of operations.

9. Formula AutoComplete.

10. Axis.

11. Category axis.

12. Value axis

13. Value \; after \; increase = Base * Percent \; for \; new \; value

Explanation:

Microsoft Excel is a software application or program designed and developed by Microsoft Inc., for analyzing and visualizing spreadsheet documents.

A spreadsheet can be defined as a file or document which comprises of cells in a tabulated format (rows and columns) typically used for formatting, arranging, analyzing, storing, calculating and sorting data on computer systems.

Some of the terminologies and features of the Microsoft Excel software includes the following;

1. Pie chart: a chart that shows the relationship of each part to a whole.

2. Goal seek: a what-if-analysis tool that finds the input needed in one cell to arrive at the desired result in another cell.

3. Relative reference cell: in a formula, the address of a cell based on the relative position of the cell that contains the formula and the cell referred to in the formula.

4. Data marker: a column, bar, area, dot, pie slice, or other symbol in a chart that represents a single data point.

5. Chart sheet: a workbook sheet that contains only a chart.

6. What-If-Analysis: the process of changing the values in cells to see how those changes affect the outcome of formulas in a worksheet.

7. Rate = \frac {Amount \; of \; increase}{Base}: The mathematical formula to calculate a rate of increase.

8. Order of operations: the mathematical rules for performing multiple calculations within a formula.

9. Formula AutoComplete: the excel feature which, after typing - and the first letter of a function, displays a list of function names.

10. Axis: a line that serves as a frame of reference for measurement and that borders the chart plot area.

11. Category axis: the area along the bottom of a chart the identifies the categories of data, also referred to as the x-axis.

12. Value axis: a numerical scale on the left side of a chart that shows the range of numbers for the data points, also referred to as the y-axis.

13. Value \; after \; increase = Base * Percent \; for \; new \; value: the formula for calculating the value after an increase by multiplying the original value the base by the percent for new value.

5 0
3 years ago
Which term describes an event where a person who does not have the required clearance or access caveats comes into possession of
notka56 [123]

Answer:

The answer is "compromise"

Explanation:

In computer science, the comprised system is used to describe as any technological resource, that has been negatively affected by an untrustworthy source for nondisclosure, integrity or accessibility either deliberately or inadvertently.

  • In this, the mechanical interaction from the unauthorized source or technological progress can result in compromise.
  • This helps you and the partner to meet each other's interests by taking into consideration both the positions and the solution to the main problem.

4 0
3 years ago
Read 2 more answers
Other questions:
  • Which area of the network would a college it staff most likely have to redesign as a direct result of many students bringing the
    10·1 answer
  • Information technology is the study of managing, processing, and retrieving information.
    5·1 answer
  • COMPUTER SCIENCE:PIXELS
    5·1 answer
  • Write a class named Accumulator containing: An instance variable named sum of type integer. A constructor that accepts an intege
    14·1 answer
  • What is thought to have caused the extinction of the dinosaurs?
    13·1 answer
  • User can use ______ commands to search for and correct words in a document
    13·1 answer
  • In java
    6·1 answer
  • 4.8 code practice question 2
    10·1 answer
  • Hi um... i just wanna say hi :P
    6·2 answers
  • Please help with coding assignment.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!