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
If you wanted to share a statement of the company's financial position at a certain time, you would use a _____.
Charra [1.4K]
I would say Balance Sheet

6 0
2 years ago
Read 2 more answers
What is the meaning of antimonographycationalis​
Oliga [24]

Answer:

Although this word was made up in order to be a contender for the longest word in English, it can be broken down into smaller chunks in order to understand it.

Anti- means that you are against something; monopoly means the exclusive control over something; geographic is related to geography; and the remaining part has to do with nationalism.

So this word means something like 'a nationalistic feeling of being against geographic monopoly,' but you can see that it doesn't have much sense.

(answer copied from  Kalahira just to save time)

3 0
2 years ago
Read 2 more answers
Create a TicTacToe class that initializes a 3x3 board of "-" values. We will use this class in future exercises to fully build o
kap26 [50]

Answer:

public class TicTacToe //Defining TicTacToe class

{

char board[3][3] ; //Creating a 2D array instance variable

TicTacToe() //Constructor to initialize the array with " - "

{

for( int i = 0;i<3;i++) //Loop for the row of array

{

for(int j = 0;j<3;j++) //Loop for the column of array

{

Board[i][j] = '-'; //Assigning "-" in each cell

}

}

}

public char getter() //Defining getter() method to return the array

{

return Board; //returning the array

}

}

8 0
3 years ago
How are Action Buttons different than hyperlinks?
ipn [44]

Actions buttons are different than hyperlinks in many ways.

2)They are predefined shapes.

<u>Explanation:</u>

Action buttons are predefined shapes in the PowerPoint and can be used for moving between the slides of the presentation and for referring to the hyperlinks as well.

Action buttons have a predefined shape and that shape can be used to set the functionality of that particular button as a convention. Action buttons make up a strong presentation.

Action buttons can be invoked by clicking on them or just hovering over them and various sound effects can also be added on both the events to make the presentation more engaging and attractive.

8 0
2 years ago
The data structure used for file directory is called
Aleks04 [339]
This is a tough question. I’m not sure if I’ll get it right but I’ll try.

Data structures used for file directories typically have a hierarchical tree structure, referred to as a directory structure. The tree has a root directory, and every file in that system has a unique path.

The simplest method of implementing a directory is to use a linear list of file names with pointers to the data blocks. But another way that you can format a file directory is by using a hash table. With this method, the linear list stores the directory entries, but a hash data structure is also used. The hash table takes a value computed from the file name and return the pointer to the file name any linear list.

So I think it’s C. But I’m not 100% sure.

I hope that helps.
6 0
3 years ago
Other questions:
  • Which statement is true? Group of answer choices Variables cannot be assigned and declared in the same statement Variable names
    5·1 answer
  • Which part of the cpu stores instructions for high speed access or processing
    14·1 answer
  • The following 2D array has been created:
    12·2 answers
  • Which of the following is a characteristic of the internet today? distributed network central hub lack of protocols absence of c
    5·1 answer
  • Explain the factors involved in selecting a routing protocol to be used on a network.
    12·1 answer
  • Which code will print a random number between 1 and 100?
    15·2 answers
  • You are a network administrator for your company. The network consists of a single Active Directory domain. All servers run Wind
    7·1 answer
  • How would you describe binary to someone ??<br> PLEASE ANSWER I WILL GIVE U BRAINLY!!
    15·2 answers
  • What applications would you pin to your taskbar, why?
    15·1 answer
  • 30 POINTS FOR THE CORRECT ANSWERS
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!