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
Tanya [424]
3 years ago
5

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. Input Validation: Do not accept negative numbers for test scores.
Computers and Technology
1 answer:
OleMash [197]3 years ago
6 0

Answer:

C++ Program

Explanation:

#include <iostream>

#include <iomanip>

using namespace std;

void arrSelectSort(double *, int);

void showArrPtr(double *, int);

void showAverage(double, int);

int main()

{

 //dynamically allocate an array

 //acumulator

 //averge scores

 //number of test scores

 

 double *scores,                        

 total = 0.0;                  

//average;                              

int nScores;                      

 

   //Get how many test scores the users wants to enter.

cout << "How many test scores would you like to process?";

cin >> nScores;

//condition about the scores

scores = new double[nScores];

if (scores == NULL)

 return 0;

//Get the number of each test

cout << "Enter the test scores below.\n";

 

 

 

for (int count = 0; count < nScores; count++)

{

 cout << "Test score #" << (count + 1) << ": ";

 cin >> *(scores + count);

 

}

 

//total score operation

for (int count = 0; count < nScores; count++)

{

 total += *(scores + count);

}

showAverage(total, nScores);

//the array pointers

arrSelectSort(scores, nScores);

cout << "the ascending order is: \n";

showArrPtr(scores, nScores);

 

//free memory.

delete[] scores;

scores = 0;

 

 

return 0;

 

}

// bubble sort  

void arrSelectSort(double *array, int size)

{

int temp;

bool swap;

do

{

 swap = false;

 for (int count = 0; count < (size - 1); count++)

 {

  if (*(array + count) > *(array + count + 1))

  {

   temp = *(array + count);

   *(array + count) = *(array + count + 1);

   *(array + count + 1) = temp;

   swap = true;

  }

 }

} while (swap);

}

// sort function

void showArrPtr(double *array, int size)

{

for (int count = 0; count< size; count++)

 cout << *(array + count) << " ";

cout << endl;

}

// average function

void showAverage(double total, int nScores)

{

double average;

//average operation

average = total / nScores;

 

//Display the results.

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

cout << "Average Score: " << average << endl;

}

You might be interested in
Basically, if for every row, the absolute value of the entry along the main diagonal is larger than the sum of the absolute valu
Elza [17]

Answer:

Check the explanation

Explanation:

MATLAB code:

%----------------------

function result = dominant(A)

% matrix dimensions

d = size(A);

% for loop over rows

for i = 1:d

% sum of row elements except diagonal element

sum_row =0;

% for loop over columns

for j = 1:d

% adding each elements to sum variable

sum_row = sum_row+ abs(A(i,j));

end

%subratcting diagonal element

sum_row = sum_row-abs(A(i,i));

%checking dominant condition

% failed once means matrix is not diagonal dominant

if abs(A(i,i))< sum_row

result = 'false';

return;

end

end

% dominant condition not failed

result = 'true';

end

% matrix A

A = [ 3 -2 1; 1 -3 2; 1 2 6]

% result

result = dominant(A)

% matrix A

A = [ -2 1 2; 1 3 2; 1 -2 0]

% result

result = dominant(A)

%----------------------

Kindly check the attached output image below.

3 0
3 years ago
What does the following code do? Assume "list" is an array of int values, "temp" is some previously initialized int value, and "
____ [38]

Answer:

Counting the number of elements in the array list smaller than temp.

Explanation:

We have an array list,a previously initialized integer temp and a an integer c initialized with 0.

In the code a for loop is used to iterate over the array and it is checking if the element at jth index is less than temp if it is then increasing the variable c by 1.

Hence when the loop ends the c will be having the count of the integers in array list that are smaller than temp.

6 0
4 years ago
Mobile devices need to work within limited screen space ? true or false
wariber [46]
False. Trust me my friend
4 0
4 years ago
Read 2 more answers
A keyboard is a/an _____. interconnector port packet NAS
Molodets [167]
Interconnector would be the answer

7 0
4 years ago
On the order form worksheet, unlock cells B5 through K5? On Microsoft excel
PIT_PIT [208]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The following steps can be used to unlock the cells of the Microsoft Excel worksheet.

  1. Select the cells B5 through K5, that you want to unlock.
  2. Then choose the “Home” tab from the tab ribbon.
  3. In the “Cells” area, then select “Format” > “Format Cells“.
  4. Select the “Protection” tab.
  5. Uncheck the box for “Locked” to unlock the cells. Check the box to lock them. Select “OK“.
7 0
3 years ago
Other questions:
  • What is the mid-square method?
    6·1 answer
  • You're trying to decide which disk technology to use on your new server. the server will be in heavy use around the clock every
    10·1 answer
  • A network supplies programming and services to a series of local tv stations, or _____, which contract to preempt time during sp
    7·1 answer
  • 12.
    10·1 answer
  • What are the basic components of a Production System?
    6·1 answer
  • Clarisse is setting the white spaces at the edge of her Word document to be 1 inch. She is setting the _____.
    7·1 answer
  • Instructions:Select the correct answer.
    5·1 answer
  • ILL GIVE BRAINLIEST TO FIRST ANSWER David is adopting an iOS app from a non-retina screen to a retina screen. The app currently
    13·1 answer
  • Red + blue =<br>Red + green =<br>Magenta - blue =<br>Yellow - green =<br>Cyan - blue =​
    9·1 answer
  • Which reports indicate how traffic arrived at a website?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!