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
Which is a benefit of using the paste link option?
kherson [118]
It helps because its a faster way to copy a link .     
8 0
3 years ago
Read 2 more answers
Phishing is a broad term that describes any program that is designed to cause harm or transmit information to others without the
katrin [286]
False phishing is the fraudulent practice of sending emails purporting to be from reputable companies in order to induce individuals to reveal personal information, such as passwords and credit card numbers.
6 0
3 years ago
Explain how power surges can affect computers and how this problem can be minimised or removed<br>​
Crank

Answer:

It places electrical pressure on the wires in your computer, causing them to heat up and burn. Some wires may melt and even if your computer survives the surge, the strain alone can cause damage in the long run. A way to minimize a power surge is to use a surge protector.

6 0
3 years ago
Write a program that asks the user for a word. Next, open up the movie reviews.txt file and examine every review one at a time.
Pie

Answer:

Wah?

Explanation:

6 0
3 years ago
How do you create multiple columns in Word?
mrs_skeptik [129]

Answer:

I think it's B

Explanation:

it sounded right to me.

7 0
3 years ago
Other questions:
  • True or false? It is just too challenging to have different password for every
    12·1 answer
  • Use your own words to describe how IT/IS can support major functional areas in the business. Discuss at least two of these areas
    14·1 answer
  • If you want to copy text formatting from one area of your document to another area, _____.
    5·2 answers
  • Which of these statements makes the most sense? a folder is contained within a file. a file is contained within a folder. a driv
    9·2 answers
  • You are part of the team to implement new software at XYZ Inc. The employees at XYZ Inc. trust the results of the old software p
    15·1 answer
  • The best place to start when you are looking for information about a device or an application is the ____ of the company that ma
    14·1 answer
  • If a function doesn’t return a value, the word _________ will appear as its return type.
    6·1 answer
  • What can be the maximum possible length of an identifier 3163 79 can be of any length​
    5·1 answer
  • 8.2 Code Practice Edhesive
    6·1 answer
  • The appropriate semaphore in C to give one more turn to writer so it can clean up IPC objects is WRITE_SEM. Is it true or false
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!