Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

My code so far 125% Programming Assignment #3, Pointers Create a C+ console appl

ID: 3586783 • Letter: M

Question

My code so far
125% Programming Assignment #3, Pointers Create a C+ console application to store points for contestants in a contest. Ask the user for the number of contestants. Create two parallel dynamic arrays, one t one to store integer scores from zero to 100. Do not accept out of range n user for each name and the score one at a time the names and umbers. Ask the you encounter the end of the array, print all names and scores, Also, print the average and indicate whether each score is above or below average verage: 91.67 ames Example: Scores Above/Below 95 Above average Ray Ranirez 89 Below average White 91 Below average ary Brown Sarah Requirements: 1) Add comments as you code. Do NOT wait until you are done coding. Also, in the beginning of your codes include the following comments: a. Purpose of the program b. Name of the author

Explanation / Answer

/* Purpose : Store points for contestants and check whether their points are greater than average or not
Author : BALBEER ANAND
Date : 05/10/2017
*/

#include <bits/stdc++.h>
using namespace std;

void input(vector<int> p, vector<string> str, int s)
{
string name;
int point;
for(int i=0;i<s;i++)
{
cin>>name;
str.push_back(name);
cin>>point;
if(point>=0 && point<=100)
p.push_back(point);
else
{
while(point<0 || point>100)
cin>>point;
p.push_back(point);
}
}
}

double cal_average(vector<int> p, int s)
{
double a;
for(int i=0;i<s;i++)
a+=p[i];
a=a/(double)s;
return a;
}

void print_result(vector<int> p, vector<string> str, int s, double a)
{
cout<<"Names Scores Above\Below"<<endl;
for(int i=0;i<s;i++)
{
cout<<str[i]<<" "<<p[i]<<" ";
if(p[i]>a)
cout<<"Above Average"<<endl;
else if(p[i]==a)
cout<<"Equal to Average"<<endl;
else
cout<<"Below Average"<<endl;
}
}

int main()
{
int k=1,s;
double avg;
while(k==1)
{
cin>>s;
vector<int> arrPoint;
vector<string> arrName;
input(arrPoint,arrName,s);
avg=cal_average(arrPoint,s);
print_result(arrPoint,arrName,s,avg);
arrName.clear();
arrPoint.clear();
cout<<" Do you want to continue? Press 1 to continue and 0 for exit ";
cin>>k;
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote