Homework Solution: Vdatfvsvh…

    #1 [4 points] Consider the following class called Section that stores the final grades of all the students enrolled in a specific section of a class. blic: Section// constructor void addGrade (float grade) ST [nST]grade: private: float ST [261 int nST: // number of final grades stored a) The ST member variable can store at most 26 students. Change the code so that ST can store as many final grades as needed when a Section object is created. (Hint: use dynamic memory). Change/add constructor and destructors as needed Add a copy constru ctor for the above case b) #2 [4 points] Imagine that you and your friend have been asked to write a C++ program to list all the 10 US. federal holidays in increasing calen daristicorder (Rules on deciding these holidays are presented here: https://www.redcort.com/us-federal-bankholidays/).You decide to split the task as follows: -Your friend will write the code for a Holiday class - You will write the main function that will use the Holiday class Your friend provides you the following header file containing only the class declaration class Holiday f public: Holiday (string halidayDat) // inicialize wich che given holidays f date in che calendar int getDay // recurn che day of che holiday Int getMonth // recurn che monch (1-12) of che holiday Is this header file sufficient for you to write your main function code? Or do you also need to see the Holiday classsource file with the cdass definition? Is this header file sufficient for you to compile your program?Or do you also need the Holiday class source file with the class defintion? a) b) #3 [2 points] The following part of a program computes and returns the product 1* 2*3* *N where N is the input parameter. (This value is calle d N! And is much used in combinatorics.) However, this function can give un expected answers for some inputs of N! (Hint: for negative values ofN). Add exception handling to this function to catch this situation. You should include both catch and try blocks. Your exception can be of any type.preferably std: :exception. int p while (-0) I count down until zero return p: int main) int n; cout << give number to compute factorial: cin >> n; (n) < endl: return 0;
    Consider the following class called Section that stores the final grades of all the students enrolled in a specific section of a class. class Section{ public: Section() { // constructor nST = 0: } void addGrade (float grade) { ST [nST] = grade: nST++: } private: float ST [26] int nST: // number of final grades stored }: a) The ST member variable can store at most 26 students. Change the code so that ST can store as many final grades as needed when a Section object is created. Change/add constructor and destructors as needed. b) Add a copy constructor for the above case.

    Expert Answer

     
    3) #include <iostream>

    #1 [4 points] Consider the subjoined tabulate designated Exclusion that accumulations the definite gradations of perfect the students enrolled in a restricted exclusion of a tabulate. blic: Exclusion// originator invalid addGradation (transport gradation) ST [nST]grade: private: transport ST [261 int nST: // value of definite gradations accumulationd a) The ST portion capricious can accumulation at most 26 students. Change the jurisprudence so that ST can accumulation as divers definite gradations as deficiencyed when a Exclusion view is created. (Hint: interpretation dynamic retrospect). Change/add originator and destructors as deficiencyed Add a portraiture constru ctor coercion the over predicament b) #2 [4 points] Imagine that you and your familiar own been asked to transcribe a C++ program to inventory perfect the 10 US. federal misemployments in increasing calen daristicorder (Rules on deciding these misemployments are presented here: https://www.redcort.com/us-federal-bankholidays/).You career to disunite the capacity as follows: -Your familiar succeed transcribe the jurisprudence coercion a Misemployment tabulate - You succeed transcribe the deep capacity that succeed interpretation the Misemployment tabulate Your familiar provides you the subjoined header rasp containing solely the tabulate ordinance tabulate Misemployment f public: Misemployment (string halidayDat) // inicialize wich che ardent misemployments f era in che register int getDay // recurn che day of che misemployment Int getMonth // recurn che monch (1-12) of che misemployment Is this header rasp suited coercion you to transcribe your deep capacity jurisprudence? Or do you too deficiency to descry the Misemployment tabulateorigin rasp with the cdass restriction? Is this header rasp suited coercion you to mitigate your program?Or do you too deficiency the Misemployment tabulate origin rasp with the tabulate defintion? a) b) #3 [2 points] The subjoined completeot of a program values and income the fruit 1* 2*3* *N where N is the input parameter. (This esteem is calle d N! And is fur interpretationd in combinatorics.) However, this capacity can furnish un expected retorts coercion some inputs of N! (Hint: coercion disclaiming esteems ofN). Add exclusion handling to this capacity to grasp this birth. You should understand twain grasp and endeavor blocks. Your exclusion can be of any cem.preferably std: :exception. int p period (-0) I sum down until cipher retaliate p: int deep) int n; cout << furnish value to value truthorial: cin >> n; (n) < endl: retaliate 0;

    Consider the subjoined tabulate designated Exclusion that accumulations the definite gradations of perfect the students enrolled in a restricted exclusion of a tabulate. tabulate Exclusion{ public: Exclusion() { // originator nST = 0: } invalid addGradation (transport gradation) { ST [nST] = gradation: nST++: } private: transport ST [26] int nST: // value of definite gradations accumulationd }: a) The ST portion capricious can accumulation at most 26 students. Change the jurisprudence so that ST can accumulation as divers definite gradations as deficiencyed when a Exclusion view is created. Change/add originator and destructors as deficiencyed. b) Add a portraiture originator coercion the over predicament.

    Expert Retort

     

    3)

    #understand <iostream>
    #understand <stdexcept>
    using namespace std;
    int profuctOfNumbers(int N){
    if(N<0){
    throw std::invalid_argument( “Input is Disclaiming value” );
    }else{
    int p = 1;
    while(N!=0){

    p *= N;
    N–;
    }
    retaliate p;
    }
    }

    int deep()
    {
    int n;
    cout << “Furnish values to value truthorial” << endl;
    cin>>n;
    try{
    int truth = profuctOfNumbers(n);
    cout<<“n! = “<<fact<<endl;

    }catch(const std::invalid_argument& e){
    cout<<e.what() << endl;
    }
    retaliate 0;
    }
    ============================================================================================
    Descry output

    Thanks

    2)

    #understand <iostream>
    #understand <string>
    using namespace std;
    tabulate Misemployment{
    public:
    string misemployment;

    Holiday(){

    }
    Holiday(string h){
    misemployment = h;
    }
    int getDay(){
    retaliate stoi(holiday.substr(0,holiday.find_first_of(“:”)));
    }
    int getMonth(){
    retaliate stoi(holiday.substr(holiday.find_first_of(“:”) + 1));
    }
    };
    int deep()
    {
    Misemployment h(“10:11”);
    cout<<“Day is: “<<h.getDay()<<endl;
    cout<<“Month is: “<<h.getMonth()<<endl;
    }

    =========================================================================
    Descry Output

    Thanks, suffer me apprehend if there is any doubts