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]
3 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]3 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
How does an operating system manage peripheral devices?
azamat

Answer:

Device management controls peripheral devices by sending them commands in their proprietary machine language. The software routine that deals with each device is called a "driver," and the OS requires drivers for each of the peripherals attached to the computer.

Explanation:

4 0
3 years ago
Plz can someone tell me the answers ?
Ganezh [65]

Answer:

you can

Explanation:

you can

5 0
3 years ago
Read 2 more answers
A. Convert decimal 37 to binary
lisabon 2012 [21]

Answer:

100101

25

5E7

101000011100

Explanation:

4 0
3 years ago
You can easily view the ruler on a document by selecting the Show Ruler button located _____.
Ket [755]
In the “View” tab in the Ribbon.
7 0
3 years ago
Read 2 more answers
Which activity is a case of identity theft
dezoksy [38]
<span>Criminal identity theft (posing as another person when apprehended for a crime)Financial identity theft (using another's identity to obtain credit, goods and services)Identity cloning (using another's information to assume his or her identity in daily life)Medical identity theft (using another's identity to obtain medical care or drugs)<span>Child identity theft]


cite: wikipedia</span></span>
4 0
3 years ago
Read 2 more answers
Other questions:
  • The ________ model allows the owner of a resource to manage who can or cannot access the item. Owners maintain this access throu
    8·1 answer
  • How do computers perform complicated tasks built from simple instructions?
    14·1 answer
  • Given the commands below, what do they do? for (position = 1 through aList.getLength()/2) { a = aList.getEntry(aList.getLength()
    11·1 answer
  • Lonic compounds are also known as <br> a. salts <br> b. valence <br> c.organic <br> d.elements
    10·2 answers
  • You often insert your company's logo into documents you create. One way to make it easier for you to quickly insert it is to sav
    10·1 answer
  • Can i have information about skrillex hobbies
    6·1 answer
  • What types of tools are used in the process of a digital or network investigation?
    12·1 answer
  • 3.1.1 What type of goods are car radio and remote control.​
    12·1 answer
  • A term to describe articles that can be displayed in their entirety,as opposed to abstract and references only
    11·1 answer
  • Which workbook view is used most often in Excel?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!