Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm getting a few errors but I don't know why I am getting them because I did declare it. I'm using Microsoft Visual Studio 2012,

I'm getting a few errors but I don't know why I am getting them because I did declare it. I'm using Microsoft Visual Studio 2012, can someone go through it and use these numbers as the 6 scores: 89, 94, 100, 78, 84, 65 to input if output works. Program should display the sorted list of scores and averages with appropriate headings. Use pointer notation rather than array notation whenever possible. Input Validation: Do not accept negative numbers for test scores.

Error 1 error C2062: type 'double' unexpected 85

Error 2 Error 2 error C2065: 'average' : undeclared identifier 92

code:

#include

#include using namespace std;

//Function prototypes void sortTestScores(int *TestScores, int size_Test); double avgTestScore(int *TestScores, int size_Test); void printTestScores(int *TestScores, int size_Test);

int main() { //Define variables int *TestScores; int size_Test, score; double average;

//Get the number of test scores you want to average cout << "How many test scores do you want to enter?"; cin >> size_Test;

//Dynamically allocate an array large enough to hold that many scores TestScores = new int[size_Test]; //Get test scores cout << "Enter " << size_Test << " positive test scores below:" << endl;

for (int i=0; i> score;

// Input validation. Only numbers between 0-100 while (score<0 || score>100) { cout << "You must enter a score that is positive" << endl; cout << "Please enter again: "; cin >> score; } TestScores[i]=score; }

//Dsiplay the results cout << "Test Scores: "; printTestScores(TestScores, size_Test); sortTestScores(TestScores, size_Test);

cout << "The test scores, sorted in ascending order, are: "; printTestScores(TestScores, size_Test);

average = avgTestScore(TestScores, size_Test);

cout << fixed << showpoint << setprecision(2); cout << "The average of all the test scores is " << average << endl;

system ("pause"); return 0; }

//Accepts a dynamic array of test scores and size of array, then sorts in ascending order //Sort function implementation void sortTestScores(int *TestScores, int size_Test) { int *last=TestScores+size_Test; //get last location of array

for (int *first = TestScores; first < last-1; first++) { for(int *next=first+1; next

} }

}

//calculates and returns average of test scores double arrAvgScore (double *TestScores, int size_Test) { int total = 0, double average; int *arranged; for (int i=0; i < size_Test; i++) { total+= *arranged; arranged++; } average= double(total) / size_Test; return average; }

//Prints test scores stored in array void printTestScores(int *TestScores, int size_Test) { int *arranged=TestScores; for (int i=0; i < size_Test; i++) { cout << *arranged << " " << arranged++ << endl; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions