1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Reil [10]
2 years ago
7

Write a program that dynamically allocates an array large enough to hold a user-defined number of test scores. Once all the scor

es are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the sorted list of scores and averages with appropriate headings. Use pointer notation rather than array notation whenever possible.
Computers and Technology
1 answer:
Anastasy [175]2 years ago
6 0

Answer:

// Program written in C++

// Comments are used to explain some lines

#include <iostream>

#include <iomanip>

using namespace std;

// Functions

void getData(double *, int);

void selectionSort(double *, int);

double getAverage(double *, int);

void displayData(double *, int, double);

int main() //Main Method

{

double *ToTest, // To dynamically allocate an array

Average; // To hold the average of the scores

int Scores; // To hold number of scores

// Get number of scores

cout << "Number of average to find? ";

cin >> Scores;

// Allocate an array to number of scores

ToTest = new double[Scores];

getData(ToTest, Scores);

selectionSort(ToTest, Scores);

Average = getAverage(ToTest, Scores);

printData(ToTest, Scores, Average);

return 0;

}

//Get Data

void getData(double *ToTest, int Scores)

{

cout << "Enter each scores.\n";

for (int i = 0; i < Scores; i++)

{

do

{

cout << "Score #" << (i + 1) << ": ";

cin >> *(ToTest + i);

if (*(ToTest + i) < 0)

{

cout << "Scores must be greater than 0.\n"

<< "Re-enter ";

}

} while (*(Test + i) < 0);

}

}

// Selection Sort

void selectionSort(double *ToTest, int Scores)

{

int startscan, minIndex;

double minValue;

for (startscan = 0; startscan < (Scores - 1); startscan++)

{

minIndex = startscan;

minValue = *(ToTest + startscan);

for (int i = startscan + 1; i < Scores; i++)

{

if (*(ToTest + i) < minValue)

{

minValue = *(Test + i);

minIndex = i;

}

}

*(ToTest + minIndex) = *(ToTest + startscan);

*(ToTest + startscan) = minValue;

}

}

// Calculate Average

double getAverage(double *ToTest, int Scores)

{

double Total;

for (int i = 0; i < Scores; i++)

{

Total += *(ToTest + i);

}

return Total / Scores;

}

// Print Data

void printData(double *ToTest, int Scores, double Avg)

{

cout << "\n Test scores\n";

cout << "Number of scores: " << Scores << endl;

cout << "Scores in ascending-order:\n";

for (int i = 0; i < Scores; i++)

{

cout << "#" << (i + 1) << ": " << *(ToTest + i) << endl;

}

cout << fixed << showpoint << setprecision(2);

cout << "Average score: " << Avg << endl;

}

You might be interested in
When the atmosphere has too much carbon dioxide in it, the oceans absorb some of it to achieve a new balance. This is an example
horsena [70]
The answer is B. 
A geochemical cycle. 
8 0
3 years ago
Read 2 more answers
How can you employ one of the most powerful interactive business tools on the Internet today?
Dovator [93]

Answer:start a blog. I read the book.

Explanation:

7 0
3 years ago
I'm curious why I would need to know this on a school learning site.
zhannawk [14.2K]
no idea either lol, I mean school forces you to learn





..
4 0
3 years ago
All of the language commands that the CPU understand make up the CPU's
disa [49]
I think assembly level command mov ,push ,call
5 0
3 years ago
What is the importance of using the proper markup language?
Klio2033 [76]

the answer is D. without the right tags the content wont be accurately indexed

3 0
3 years ago
Read 2 more answers
Other questions:
  • Which sparkline type is best for displaying trends in data changes over time?
    11·1 answer
  • What are dividends? AA small part, or share, of a company. BA type of savings account that grows over time. CA distribution of a
    5·1 answer
  • In a transaction-processing system (TPS), if the TPS database can be queried and updated while the transaction is taking place,
    12·1 answer
  • True or false.the color attribute cannot recognized the hexadecimal code.
    7·2 answers
  • Review the two e-mail messages below for their adherence to the guidelines for professional e-mail correspondence you have learn
    6·1 answer
  • Your boss is very skeptical about the idea of storing his files up in the cloud rather than on a local storage drive. He asks yo
    7·1 answer
  • 1
    13·1 answer
  • How should tools be stored <br>​
    13·1 answer
  • EASY POINTS who is your favorite in family<br> 1. mom<br> 2. dad<br> 3. sister<br> 4. brother
    10·2 answers
  • Describe psychographic differences among the past five generations of Americans that you learned about in this course. What type
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!