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
You are investigating a problem between two wireless bridges and you find that signal strength is lower than expected. Which of
son4ous [18]

The most likely problem that led to the signal strength is lower than expected is a D. Wrong antenna type

<h3>What is a Computer Network?</h3>

This refers to the inter-connectivity between wireless bridges to connect a computer system to the world wide web.

Hence, we can see that based on the fact that there is troubleshooting going on about two wireless bridges where the signal strength is lower than expected, the most likely problem that led to the signal strength is lower than expected is a D. Wrong antenna type

Read more about computer networks here:

brainly.com/question/1167985

#SPJ1

8 0
2 years ago
Advantages of email over traditional mail​
dalvyx [7]

Answer: emails are delivers very fast compared to regular traditional mail

Explanation:

6 0
1 year ago
Prepare a algorithm visualization for the Tower of Hanoi when 4 disks are to be moved from spindle #1 to spindle #3.
Setler [38]

Answer:

follwing is the code for Tower of Hanoi for n disks.

#include <iostream>

using namespace std;

void towofhan(int n,char source,char aux,char dest)//function for tower of hanoi..

{

if(n<0)

return ;

   if(n==1)//base case.

   {

       cout<<"Move disk 1 from "<<source<<" to spindle "<<dest<<endl;

       return;

   }

   towofhan(n-1,source,dest,aux);//recursive call.

   cout<<"move disk "<<n<<" from "<<source<<" to spindle "<<dest<<endl;

   towofhan(n-1,aux,source,dest);//recursive call.

}

int main() {

   int n=4;

   towofhan(n,'1','2','3');//function call.

   return 0;

}

Explanation:

If there is only 1 disk then we have to move the disk from source to destination.

Then after that we will apply recursion to solve the problem.

We have to work on only nth disk else will be done by the recursion.

First call recursion to move n-1 disks from source to auxiliary.

Then move nth disk from source to destination spindle.

Now move n-1 disks that are on the auxiliary spindle to destination spindle.

6 0
3 years ago
Business process re-engineering
Lorico [155]

Answer:

d. asks you to rethink the way you are doing your work.

Explanation:

A business strategy generally sets the overall direction for a business and as it focuses on defining how a business would achieve its goals, objectives, and mission; as well as the funds and material resources required to implement or execute the business plan.

Business process re-engineering can be defined as a strategic technique which typically involves being innovative while discarding old business processes, procedures and ideas in order to achieve maximum level of success.

Hence, business process re-engineering asks you to rethink the way you are doing your work.

For example, if you use manual labor for the production of your goods but then decided to start using automated machines for the production and packaging of your products. .

8 0
3 years ago
Animal wisdom/ the last wolf .compare and contrast the overall feeling of each poem
masha68 [24]
List the poem please. I won’t be able to answer without it.
3 0
3 years ago
Other questions:
  • What is the device called which typically combines the capabilities of a scanner, printer, fax, and copying machine?
    15·1 answer
  • What are the advantages of a peer-to-peer network? Select all that apply.
    15·1 answer
  • How many different passwords are possible if each character may be any lowercase letter or digit, and at least one character mus
    6·1 answer
  • Discuss the role that Cloud Computing plays in an organization and the potential impact that Cloud Computing has on IT.
    8·1 answer
  • What file system allows you to continue to add files to a CD or DVD disc after the initial burn, as long as there is room on the
    14·1 answer
  • _ is a term used for license like those issues by creative commons license as an alternative to copyright
    8·1 answer
  • Can somebody tell me the Minecraft command to clear an entire world and destroy every block if u Dunno please don’t answer &gt;-
    13·1 answer
  • unlike tv or newspaper ads, internet communications are interactive, and consumers can choose which messages and information the
    5·1 answer
  • Loops are frequently used to ____; that is, to make sure it is meaningful and useful.
    9·1 answer
  • (2 points) starting from the root node, we want to populate a bst with the keys in a given list without altering the key order.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!