(Solved) : Question Allowed Use Files Loops Functions Beginning C Thank Much Q May Change Arguments P Q42761297 . . .

Question: Only allowed to use files, loops, and functions whichis the beginning of the C++ thank you so much!

  • Q: May I change the arguments passing in the functions?

    A: I am not sure can you don’t change the arguments passing inthe function?

    A CIS 22A class has two midterm exams with a score between 0 and100 each. Fractional
    scores, such as 88.3 are not allowed. The students’ ids and midtermexam scores are
    stored in a text file as shown below:
    DH232 89 92 // id exam1 exam2
    Write a program that reads data from an input file named exams.txt,calculates the
    average of the two midterm exams scores for each student and theclass average for each
    midterm exam, and writes a report to an output file namedresults.txt. When you
    calculate the class average for each exam do not take 0 intoaccount.
    Input: Create a new text file and name it exams.txt, then copy andpaste the following
    data into this file. Assume that the input file has an unknownnumber of lines.
    DH232 89 92
    DR123 100 95
    AJ222 98 85
    SW111 0 0
    12AB1 82 91
    516BC 99 92
    2ABCD 100 88
    333XY 92 75
    TY4XZ 43 0
    AC234 78 93
    9QWE9 45 0
    JP200 89 98
    AK323 100 91

    Screen Output: Display a welcome message and the purpose of theprogram, including
    the names of the input and output files. Display the number ofstudents, and finally,
    display an “end of the program” message.
    File Output: Write to a file named results.txt a report that beginswith a title and a
    header of your choice. It contains the exam scores and theiraverage for each student and
    the class average for each midterm exam, the number of students inthe class, number of
    non-zero scores for the first exam, and the number of non-zeroscores for the second
    exam. Here is an example:

    ==========================
    CIS 22A
    Midterm Exams Statistics
    ==========================
    ID Exam1 Exam2 Average
    ==========================
    DR123 100 95 97.5
    TY4XZ 43 0 21.5
    AC234 78 93 85.5
    ==========================
    Number of students: 3
    3 students took the first exam.
    Exam 1 Class Average: 73.66
    2 students took the second exam.
    Exam 2 Class Average: 94.00

    / NOTE: You must write documentation for each function – seenext page
    Design: Your program should include 5 functions in addition tomain(), as shown
    below:
    printInfo – to display a welcome message and some information aboutthe program
    open the input file
    open the output file
    for each student repeat the following:
    getStuData – read a student’s id and scores // see getRectangle in6B
    calcAvg – calculate a student’s average score; // seecalculateRectangle
    writeStuData – to write to the output file a student’s id, examscores and
    average // see writeRectangle
    close the input file
    close the output file
    printEnd – to display an end-of-the-program message
    NOTE: You must write documentation for each function. Choose astyle or create your
    own style and be consistent. A one-line comment is not anacceptable style. Here are
    some examples:

    Example 1
    //*********************************************************
    // This function accepts the number of hours worked as an
    // argument and returns the employee’s pay for
    // non-overtime hours.
    //*********************************************************
    Example 2
    /**********************************************************
    This function accepts the number of hours worked as an argumentand
    returns the employee’s pay for
    non-overtime hours.
    */

    ===================

  • sample

  • Project 6C: Exam Statistics

    This program that reads data from an input file namedexams.txt,
    calculates the average of the two midterm exams scores for eachstudent and
    the class average for each midterm exam, and
    writes a report to an output file named results.txt.
    *~**/

    #include
    #include
    #include

    using namespace std;

    const int DE_BUG = true;

    void printInfo(void);
    bool getStuData(void);
    void calcAvg(void);
    void writeStuData(void);
    void printEnd(void);

    int main()
    {
    // declare the variables needed in main()

    printInfo();
    // open the input file + validation
    // open the output file + validation

    while (getStuData())
    {
    calcAvg();
    writeStuData();
    // update counters
    }
    // close the input file
    // close the output file

    // display the name of the input file
    // display the name of the output file
    // display the number of students

    printEnd();
    return 0;
    }

    /*~*~*~*
    Write a comment here to describe the purporse of thisfunction.

    */
    void printInfo(void)
    {
    if (DE_BUG)
    cout << “This is the welcome function” << endl;
    }

    /*~*~*~*
    Write a comment here to describe the purporse of thisfunction.

    */
    bool getStuData(void)
    {
    if (DE_BUG)
    cout << “This is the getStuData function” <<endl;
    return false; // change this line (see 6B)
    }

    /*~*~*~*
    Write a comment here to describe the purporse of thisfunction.

    */
    void calcAvg(void)
    {
    if (DE_BUG)
    cout << “This is the calcAvg function” << endl;
    }

    /*~*~*~*
    Write a comment here to describe the purporse of thisfunction.

    */
    void writeStuData(void)
    {
    if (DE_BUG)
    cout << “This is the writeStuData function” <<endl;
    }

    /*~*~*~*
    Write a comment here to describe the purporse of thisfunction.

    */
    void printEnd(void)
    {
    if (DE_BUG)
    cout << “This is the END function” << endl;
    }

Expert Answer


Answer to Question: Only allowed to use files, loops, and functions which is the beginning of the C++ thank you so much! Q: May I …

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us