Question

The checkpoint for Lab 7 requires you to define StudentRecord member functions having the following prototypes:...

The checkpoint for Lab 7 requires you to define StudentRecord member functions having the following prototypes:

void setNumTests(int);
void setScore(int index, double newVal);

1) Write the complete implementation code for the setNumTests() member function that would appear below the class interface code and above main() in the Lab7Driver.cpp file.

2) Write the complete implementation code for the setScore() member function that would appear below the class interface code and above main() in the Lab7Driver.cpp file.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go this code and let me know if u need any changes in this.Thank You
_________________

#include <iostream>
using namespace std;

//Declaring class
class StudentRecord
{
private:
int noOfTests;
double *testScores;
public :
    //Function Declarations
void setNumTests(int);
void setScore(int index, double newVal);
StudentRecord(int);
   double average();
};

//Function Implementations
void StudentRecord::setNumTests(int size)
{
   this->noOfTests=size;
}

StudentRecord::StudentRecord(int size)
{
   setNumTests(size);
   this->testScores=new double[size];
}
void StudentRecord::setScore(int index, double newVal)
{
   testScores[index]=newVal;
}

//This function will calculate the average of test scores
double StudentRecord::average()
{
   double sum=0;
   for(int i=0;i<noOfTests;i++)
   {
       sum+=testScores[i];
   }
   return sum/noOfTests;
}

   int main()
   {
       //Declaring variables
       int size;
       double testScore;
      
       //Getting the input entered by the user
cout<<"Enter no of tests :";
cin>>size;
  
StudentRecord s(size);
  
//Getting the Test Scores entered by the user
for(int i=0;i<size;i++)
{
   cout<<"Enter Test Score#"<<i+1<<":";
   cin>>testScore;
   s.setScore(i,testScore);
       }
      
       //Displaying the average
       cout<<"Average of test Scores :"<<s.average()<<endl;
      
       return 0;
   }

____________________________

Output:

_______________.Thank You

Add a comment
Know the answer?
Add Answer to:
The checkpoint for Lab 7 requires you to define StudentRecord member functions having the following prototypes:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Code Lab Help (C++)

    Write the interface (.h file) of a class Player containing:A data member name of type string .A data member score of type int .A member function called setName that accepts a parameter and assigns it to name . The function returns no value.A member function called setScore that accepts a parameter and assigns it to score . The function returns no value.A member function called getName that accepts no parameters and returns the value of name .A member function called...

  • Overview This checkpoint is intended to help you practice the syntax of operator overloading with member...

    Overview This checkpoint is intended to help you practice the syntax of operator overloading with member functions in C++. You will work with the same money class that you did in Checkpoint A, implementing a few more operators. Instructions Begin with a working (but simplistic) implementation of a Money class that contains integer values for dollars and cents. Here is my code: /********************* * File: check12b.cpp *********************/ #include using namespace std; #include "money.h" /**************************************************************** * Function: main * Purpose: Test...

  • For this lab you must write a complete class in C++. This will be a class...

    For this lab you must write a complete class in C++. This will be a class named BankAccount. This class must have the following private variables: 1. accountHolderName : string 2. balance : double 3. interestRate: double This class must have the following public constructor: 1. BancAccount(name : string, balance : double, rate : double) This class must have the following public member functions: 1. getAccountHolderName() : string a. returns the account holders name 2. getBalance() : double a. returns...

  • You are to write three functions for this lab: mean, remove, display. Download the main.cpp file...

    You are to write three functions for this lab: mean, remove, display. Download the main.cpp file provided to get started. Read the comments in the main function to determine exactly what the main function should do. //include any standard libraries needed // - Passes in an array along with the size of the array. // - Returns the mean of all values stored in the array. double mean(const double array[], int arraySize); // - Passes in an array, the size...

  • PLEASE HELP!!! C PROGRAMMING CODE!!! Please solve these functions using the prototypes provided. At the end...

    PLEASE HELP!!! C PROGRAMMING CODE!!! Please solve these functions using the prototypes provided. At the end please include a main function that tests the functions that will go into a separate driver file. Prototypes int R_get_int (void); int R_pow void R Jarvis int start); void R_fill_array(int arrayll, int len); void R_prt_array (int arrayl, int len) void R-copy-back (int from[], int to [], int len); int R_count_num (int num, int arrayll, int len) (int base, int ex) 3. Build and run...

  • Write a C++ program In this assignment you will complete the definition of two functions that...

    Write a C++ program In this assignment you will complete the definition of two functions that implement the repeated squaring algorithm described in the Stamp textbook on pages 98-99. Note that your implementation should not use the pow() function, the powl() functions, or any other built-in exponentiation functions. program4-driver.cpp - This file contains a completed main() function that serves as the driver to parse the command line, pass the values to the powerModN() function, and print the result. Make no...

  • Please answer all the questions thank you 1) (Classes – 20 Points) Consider the following class...

    Please answer all the questions thank you 1) (Classes – 20 Points) Consider the following class declaration for Time to complete the questions below: DO NOT WRITE MORE THAN ASKED FOR. class Time private: int hours; int minutes; public: Time(); Time (int , int m = 0); void addMin(int m); void addHr(int h); void reset(int h = 0, int m = 0); Time operator+(const Time & t) const; Time operator-(const Time & t) const; Time operator*(double n) const; friend Time...

  • This program has an array of floating point numbers as a private data member of a...

    This program has an array of floating point numbers as a private data member of a class. The data file contains floating point temperatures which are read by a member function of the class and stored in the array. Exercise 1: Why does the member function printList have a const after its name but getList does not? Exercise 2: Fill in the code so that the program reads in the data values from the temperature file and prints them to...

  • Dynamic MathStack The MathStack class shown in this chapter only has two member functions: add and...

    Dynamic MathStack The MathStack class shown in this chapter only has two member functions: add and sub . Write the following additional member functions: Function Description mult - Pops the top two values off the stack, multiplies them, and pushes their product onto the stack. div - Pops the top two values off the stack, divides the second value by the first, and pushes the quotient onto the stack. addAll - Pops all values off the stack, adds them, and...

  • For this lab, you will need to write the following functions in table.cpp, and add function...

    For this lab, you will need to write the following functions in table.cpp, and add function prototypes for them to table.h and invoke the functions in main.cpp. * int countNodes(node * root) Recursively count the number of the nodes in the tree. * int sumLeaves(node * root) Recursively sum all of the leaf nodes in the tree. You must use the functions with these exact function prototypes. ****************************************************************************** main.cpp #include "table.h" #include <iostream> using namespace std; int main() { node...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT