This is an OPTIONAL project and is intended to allow the user to raise their course averageby completing the project and demonstrating their knowledge of C++. The grade receivedon this project will be...

1 answer below »
This is an OPTIONAL project and is intended to allow the user to raise their course averageby completing the project and demonstrating their knowledge of C++. The grade receivedon this project will be used to replace the LOW exam grade OR the LOW lab grade, but notboth, and NOT the final exam. I will expect that the program will be properly tested,including all functions.This is not a group project; all work is to be completed by the individual. I will be lookingfor any violations.Problem: Develop a program which will read numbers from the keyboard into an array oftype ‘int’. You may assume that there will be no more than 50 distinct (unique) entries inthe array. Your program allows any number of numbers to be entered, but only 50 may beunique. The output is to be a two-column list. The first column is a list of the distinctnumber elements, the second column is the count of the number of occurrences of eachdistinct number. The list will be sorted on entries in the first column, largest to smallest.The user will enter a series of numbers, terminated with an entry of -999. At that point, theprogram should perform the sort of the columns and output the results.As an example, if the user were to input the following sequence of numbers:-12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12 -999The output should be:N Count---------------4 23 32 21 4-1 1-12 4Due: Friday, May 7, 2021, midnight.This program will make use of the following constructs:• Loops• Pointers• Arrays• Searching techniques• User input• Prompts• Formatted output• Sorting of ArraysNote: Late projects WILL NOT be accepted,regardless of circumstance. Course grades are duethe Monday following finals and I must have timeto grade these as well as the final and get yourgrades developed.Basic Algorithm:• Initialize the data in the program• Prompt the user for a series of numbers• Loop until the user enters -999 (not to be added to the array).o For each new number entered:▪ Search the first column to see if the number has beenentered previously.• If so, increment the corresponding value in thesecond column to reflect another occurrence ofthe same number.• If not, the number has not been enteredpreviously.o Add the new number to the first column atthe next available position, not previouslyused. Use the count of distinct numbers.o Set the corresponding element in thesecond column to the value of 1.o Increment the count of unique numbersentered by the user by one.o Prompt the user for the next number.• When the user has finished entering the numbers (entered -999)o Sort the first column from highest to lowest.o With each exchange, perform the corresponding exchangein the second column.• Print the results for review• End the program.
Answered 6 days AfterApr 08, 2021

Answer To: This is an OPTIONAL project and is intended to allow the user to raise their course averageby...

Swapnil answered on Apr 10 2021
159 Votes
79944/1.cpp
#include
#include
#include
using namespace std;

#include
void datacountval(int[],int);
void datafileuser();
void userinputdata();
int main()
{
    while(1)
    {
        int choice;
        printf("1.file read\n2.user input\n3.exit\n");
        printf("select your choice:");
        cin>>choice;
        if(choice==1)
        {
            datafileuser();
        }
        else if(choice==2)
        {
            userinputdata();
        }
        else if(choice==3)
        {
            break;
        }
    }
    return 0;
}
void datafileuser()
{
    string name;
    cout<<"Enter filename:";
    cin>>name;
    fstream datafile(name,ios_base::in);
    int data[50];
    int i=0;
    int a;
    while (datafile>> a)
    {
        data[i]=a;
        i=i+1;
    }
    int n=i;
    datacountval(data,n);
}
void...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here