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
You give an object a more meaningful name by setting the object’s _________________ property.
viva [34]

Answer:

The correct answer to this question is "Name".

Explanation:

In the programming language, the object is a part of the object-oriented programming language (oops).In all (oops) programming language we use class and object. where class is a collection of data member and member function, and object is a real-world entity. An Object is an instance of a Class. When a class is created, no memory is assigned but when we create the object of the class then memory is allocated.

In this question except option (d), all options are wrong.

7 0
3 years ago
Give 3 ways you can get creative and personal while creating a PowerPoint.
kondor19780726 [428]

Answer:

People come to listen to you – your thoughts, interpretations and insights. Fancy transitions, clips, and tons of text steal from your content and delivery.

Remember: every time you hit that clicker the audience leaves you and goes to the screen.

Explanation:

7 0
4 years ago
Can someone just help Im really struggling right now<br> Tysm if you help
frutty [35]

That's really really hard, my god Cassie!

Explanation:

I don't know what the answer is. bekos Yu du not is da layer of da peyk Cassie. di ka mukhang dragon

6 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
Def test() : # do not change this line!
bogdanovich [222]
I’m sorry this is unclear . What exactly do you need .
8 0
3 years ago
Other questions:
  • What type of storage system is a hard drive on a computer?<br> Need HELP fast, please.
    9·2 answers
  • Joshe is a project leader in Tiran technologies. 75 developers and analysts work under his supervision on several projects. Thes
    12·1 answer
  • would an electromagnet with a 3.7 volt lithium ion battery have an effect on devices and/or satelite signals like cell phones​
    9·1 answer
  • Create detailed pseudocode for a program that calculates how many days are left until Christmas, when given as an input how many
    15·1 answer
  • Create a Quadrilateral, Oval, Triangle, Polygon class that are all extended from an abstract Shape class (given below). Then ext
    14·1 answer
  • Create a horizontal line across middle of the entire form. To code this the ____ values are the same.
    7·2 answers
  • PHP server scripts are surrounded by delimiters, which? *
    5·1 answer
  • What is digital scavenger hunting? A. An application that locates addresses B. A scavenger hunt where players use GPS and digita
    5·1 answer
  • Which one???????????????
    14·2 answers
  • When you try to move the desktop icon using the click and drag method and it doesn't move, what is the reason?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!