I really need help with this project I dont need help with m

I really need help with this project. I don\'t need help with making the flowchart or the psuedocode but I don\'t have any clue on how to create the program. I would really appreciate it! I also need help learning how to add the text file into the program.

The purpose of this assignment is to get experience with an array, do while loop and read and write file operations. Your goal is to create a program that reads the exam.txt file with 10 scores. After that, the user can select from a 4 choice menu that handles the user’s choices as descried in the details below. The program should display the menu until the user selects the menu option quit.

The project requirements: It is an important part of your grade that you design your application according to the following requirements.

Step 1) Create a flowchart and pseudo code to list the actions and how they should occur.

Step 2) Add the exam.txt file inside your project.

Step 3) Write the source code according to your pseudo code and the following project requirements:

1. Declare the number of scores as a const. This const is to be used as size of your array.

2. Create the first for loop to read the data from the data file into an array. If the file is not found, the program needs to terminate with this error, “Data file not found.”.

3. Once the score data has been read into the array, display a menu with 4 choices to the user as follows below. This needs to be setup as a do while and repeat the program until the user selects the menu choice 4 (Quit).

Please select 1, 2, 3, or 4:

Search score, Enter 1

Generate stats file, Enter 2

Print scores, Enter 3

Quit, Enter 4

Then set up a switch statement with these cases to handle the user’s selection.

4. If the user selects the menu choice 1, ask the user for a score, then use a loop to search for the exact match inside your array and display a message if the match was found : “Matching score found” and if the match is not found display: “The score you entered is not found”.

5. If the user selects the menu choice 2, use another loop to find the highest and lowest score figures. Then generate a new text file called stats.txt, record the average, highest and lowest score figures and save 3 numbers in that file. Then display a message to the user: “The stats.txt file has been generated. The average, highest and the smallest scores are:…(display numbers here)”

6. If the user selects the menu choice 3, use another for loop to display all scores to the user.

7. If the user selects the menu choice 4, exit the program. Otherwise, display the menu again.

Step 4) Test run your program and include your printouts of your console output screenshots that cover the following test cases:

Test case1: User enters for menu selection 1 and for score 10

Test case1a: User enters for menu selection 1 and for score 35

Test case2: User enters 2

Test case3: User enters 3

Test case4: User enters 4

Test case5: User enters 5

Solution

#include<iostream>
#include<fstream>
using namespace std;
#define MAX 10
//To display menu and accept and returns the choice
int menu()
{
    int ch;
    cout<<\"\ \ Search score, Enter 1 \";
    cout<<\"\ Generate stats file, Enter 2 \";
    cout<<\"\ Print scores, Enter 3 \";
    cout<<\"\ Quit, Enter 4 \";
    cout<<\"\ Please select 1, 2, 3, or 4: \";
    //Accept choice
    cin>>ch;
    return ch;
}
//Search for the score entered
void search(int mark[])
{
    int f = 0, score;
    //Accept score
    cout<<\"\ Enter score to search: \";
    cin>>score;
    for(int c = 0; c < MAX; c++)
    {
        //Check for the matching score entered by the user
        if(mark[c] == score)
        {
            //if found set the flag variable to 1 and comeout of the loop
            f = 1;
            break;
        }
    }
    //Check for the found status
    if(f == 1)
        cout<<\"\ Matching score found\";
    else
        cout<<\"\ Matching score not found\";
}
//Find out the highest, lowest and calculates average score
void HiLo(int m[])
{
    //Initializes the highest and lowest to the first score
    int hi = m[0], lo = m[0], tot = m[0];
    float avg;
    for(int c = 1; c < MAX; c++)
    {
        //Check for highest score
        if(hi < m[c])
            hi = m[c];
        //Check for lowest socre
        else if(m[c] < lo)
            lo = m[c];
        //Calculates the total score
        tot = tot + m[c];
    }
    //Calculates the average score
    avg = (float)tot / MAX;
    //File Write
    ofstream Wfile(\"stats.txt\");
    if (Wfile.is_open())
    {
        //Writes data to the file
        Wfile<<\"\ Highest Scores = \"<<hi;
        Wfile<<\"\ Smallest Scores = \"<<lo;
        Wfile<<\"\ Average Scores = \"<<avg;
        cout<<\"\ The stats.txt file has been generated\";
        Wfile.close();
    }
    else
        cout << \"Unable to open file\";

    cout<<\"\ Highest Scores = \"<<hi;
    cout<<\"\ Smallest Scores = \"<<lo;
    cout<<\"\ Average Scores = \"<<avg;
}
//Display all scores
void dispScore(int m[])
{
    cout<<\"\ Scores are: \ \";
    for(int c = 0; c < MAX; c++)
    {
        cout<<\"\ Score \"<<c + 1 <<\" = \"<<m[c];
    }
}
int main()
{
    //Create an array whose size is a constant
    int mark[MAX], n = 0;
    ifstream Rfile;
    //Opens exam.txt file for reading
    Rfile.open(\"exam.txt\");
    //Check file can be open or not
    if (Rfile.is_open())
    {
        //Reads data till end of file
        while(!Rfile.eof())
        {
            //Reads and stores data in array
            Rfile >> mark[n];
            n++;
        }
    }
    else
    {
        cout<<\"ERROR: Data file not found.\";
        exit(0);
    }
    Rfile.close();
    do
    {
        switch(menu())
        {
            case 1:
                search(mark);
            break;
            case 2:
                HiLo(mark);
            break;
            case 3:
                dispScore(mark);
            break;
            case 4:
            exit(0);
            default:
                cout<<\"\ Wrong Choice: \";
        }
    }while(1); //Loops till 4 is entered
}


Output

Search score, Enter 1
Generate stats file, Enter 2
Print scores, Enter 3
Quit, Enter 4
Please select 1, 2, 3, or 4: 1

Enter score to search: 90

Matching score found

Search score, Enter 1
Generate stats file, Enter 2
Print scores, Enter 3
Quit, Enter 4
Please select 1, 2, 3, or 4: 1

Enter score to search: 59

Matching score not found

Search score, Enter 1
Generate stats file, Enter 2
Print scores, Enter 3
Quit, Enter 4
Please select 1, 2, 3, or 4: 2

The stats.txt file has been generated
Highest Scores = 90
Smallest Scores = 9
Average Scores = 54.7

Search score, Enter 1
Generate stats file, Enter 2
Print scores, Enter 3
Quit, Enter 4
Please select 1, 2, 3, or 4: 3

Scores are:

Score 1 = 12
Score 2 = 15
Score 3 = 65
Score 4 = 75
Score 5 = 90
Score 6 = 9
Score 7 = 55
Score 8 = 80
Score 9 = 85
Score 10 = 61

Search score, Enter 1
Generate stats file, Enter 2
Print scores, Enter 3
Quit, Enter 4
Please select 1, 2, 3, or 4: 4

I really need help with this project. I don\'t need help with making the flowchart or the psuedocode but I don\'t have any clue on how to create the program. I
I really need help with this project. I don\'t need help with making the flowchart or the psuedocode but I don\'t have any clue on how to create the program. I
I really need help with this project. I don\'t need help with making the flowchart or the psuedocode but I don\'t have any clue on how to create the program. I
I really need help with this project. I don\'t need help with making the flowchart or the psuedocode but I don\'t have any clue on how to create the program. I
I really need help with this project. I don\'t need help with making the flowchart or the psuedocode but I don\'t have any clue on how to create the program. I

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site