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
Colt1911 [192]
4 years ago
12

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 (use any sort methods--bubble or selection--from Chapter 8). Another function should be called the calculates the average score and drop the lower test score. The program should display the sorted list of scores and average score. The program should display the sorted list of scores and average with appropriate headings. Use pointer notation rather than array notation whenever possible.
Engineering
1 answer:
Readme [11.4K]4 years ago
6 0

Answer:

#include <iostream>

#include <iomanip>

using namespace std;

//Function prototypes

void arrSelectSort(double *, int);

double arrAvgScore(double *, int);

int main()

{  

//Variables  definition

double *TestScores,  

total = 0.0,

average;

int numTest,

count;

//Enter the number of test scores you want to get to their average in ascending order

cout << "How many test scores do you wish to enter?";

cin >> numTest;

//Dynamically allocate an array large enough to hold that many scores

TestScores = new double[numTest];

//Get the test scores

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

for (count = 0; count < numTest; count++)

{

//Display score

cout << "Test Score " << (count + 1) << ": ";

cin >> TestScores[count];

 }  

// Input validation. Only numbers between 0-100

while (numTest<0)

{

cout << "You must enter a scores that non-negative" << endl;

cout << "Please enter a non-negative interger between 0 and 100: ";

cin >> TestScores[count];

}

//Calculate the total test scores

for (count = 0; count < numTest; count++)

{

total += TestScores[count];

}

average = total / numTest;

//Dsiplay the results

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

cout << "The average of all the test score is " << average << endl;

//Free dynamically allocated memory

delete [] TestScores;

TestScores = 0; //make TestScores point to null

//Display the Test Scores in ascending order

cout << "The test scores, sorted in ascending order, are: \n";

system ("pause");

return 0;

}

//Ascending order selection sort

void arrSelectSort(double *arr, int size)

{

int startScan;

double minIndex;

double minElem;  

for(startScan = 0; startScan < (size - 1); startScan++)

{

minIndex = startScan;

minElem = arr[startScan];  

}

for(int index = startScan + 1; index < size; index++)

{

if (arr[index] < minElem)

{

minElem = arr[index];

minIndex = index;  

}

}

void arrAvgScore (double *arr[], int size)

{

double total = 0;

int numTest;

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

{

total += numTest[count];

average = total / numTest;

}

}

}

You might be interested in
A well-established way of power generation involves the utilization of geothermal energy-the energy of hot water that exists nat
jeka94

Answer:

the maximum thermal efficiency is 29%

Explanation:

the maximum efficiency for a thermal engine that works between a cold source and a hot source is the one of a Carnot engine. Its efficiency is given by

Maximum efficiency= 1 - T2/T1

where

T2= absolute temperature of the cold sink (environment)= 20°C + 273 = 293

T2= absolute temperature of the hot source (hot water supply) = 140°C + 273 = 413

therefore

Maximum efficiency= 1 - T2/T1 = 1 - 293/413 = 0,29 =29%

3 0
3 years ago
Can you guys please introduce yourself​
EleoNora [17]

Answer: why?

Explanation:

6 0
3 years ago
Read 2 more answers
At an axial load of 22 kN, a 15-mm-thick × 40-mm-wide polyimide polymer bar elongates 4.1 mm while the bar width contracts 0.15
Alenkasestr [34]

Answer:

The Poisson's Ratio of the bar is 0.247

Explanation:

The Poisson's ratio is got by using the formula

Lateral strain / longitudinal strain

Lateral strain = elongation / original width (since we are given the change in width as a result of compession)

Lateral strain = 0.15mm / 40 mm =0.00375

Please note that strain is a dimensionless quantity, hence it has no unit.

The Longitudinal strain is the ratio of the elongation to the original length in the longitudinal direction.

Longitudinal strain = 4.1 mm / 270 mm = 0.015185

Hence, the Poisson's ratio of the bar is 0.00375/0.015185 = 0.247

The Poisson's Ratio of the bar is 0.247

Please note also that this quantity also does not have a dimension

3 0
3 years ago
How does heat conduction differ from convection?
Helga [31]

Explanation:

Conduction:

     Heat transfer in the conduction occurs due to movement of molecule or we can say that due to movement of electrons in the two end of same the body. Generally,  phenomenon of conduction happens in the case of solid . In conduction heat transfer takes places due to direct contact of two bodies.

Convection:

              In convection heat transfer of fluid takes place due to density difference .In simple words we can say that heat transfer occur due to motion of fluid.

7 0
3 years ago
Read 2 more answers
What is the criteria for a guard having to be used on a machine?
evablogger [386]

Answer:

Machine Safeguards must meet these minimum general requirements: Prevent contact: The safeguard must prevent hands, arms, or any other part of a worker's body from making contact with dangerous moving parts. Be secure: Workers should not be able to easily remove or tamper with the safeguard.

8 0
3 years ago
Other questions:
  • An isentropic steam turbine processes 5.5 kg/s of steam at 3 MPa, which is exhausted at 50 kPa and 100°C. Five percent of this f
    13·1 answer
  • A PMOS device with VT P = −1.2 V has a drain current iD = 0.5 mA when vSG = 3 V and vSD = 5 V. Calculate the drain current when:
    12·1 answer
  • Talc and graphite are two of the lowest minerals on the hardness scale. They are also described by terms like greasy or soapy. B
    14·1 answer
  • Water (cp = 4180 J/kg·°C) enters the 2.5 cm internal diameter tube of a double-pipe counter-flow heat exchanger at 17°C at a rat
    7·1 answer
  • Consider a two-dimensional incompressible velocity potential phi = ???????? cos theta + ????????theta, where B and L are constan
    8·1 answer
  • Looking back, I was sure that I was going to die that November afternoon. Tornado watches in Alabama are as common as eggs are f
    15·2 answers
  • For Laminar flow conditions, what size pipe will deliver 90 gpm of medium oil at 40°F (υ = 6.55 * 10^‐5)?
    12·1 answer
  • The cost of hiring new employees outpaces the raises for established employees is
    5·1 answer
  • Which state did NOT have people that got sick from the
    10·1 answer
  • Which type of Artificial Intelligence (AI) can repeatedly perform tasks of limited scope?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!