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
Do NOT mix ____________________ with used oil. A) Transmission oilB) AntifreezeC) Hydraulic fluidsD) Synthetic oil
Scorpion4ik [409]
Do not mix Antifreeze with used oil
6 0
3 years ago
The steady-state data listed below are claimed for a power cycle operating between hot and cold reservoirs at 1200 K and 400 K,
lesya692 [45]

Answer:

a. Irreversible

b. Impossible

c. Impossible

Explanation:

to determine if a case is reversible, irreversible or impossible we compare the actual efficiency to the maximum efficiency of each case

maximum efficiency of the power cycle

nmax = 1 - TC/TH

nmax = 1 - 400/1200

Check attachment for complete solution

8 0
3 years ago
Read 2 more answers
A long aluminum wire of diameter 3 mm is extruded at a temperature of 280°C. The wire is subjected to cross air flow at 20°C at
Musya8 [376]

Answer:

Explanation:

Given:

Diameter of aluminum wire, D = 3mm

Temperature of aluminum wire, T_{s}=280^{o}C

Temperature of air, T_{\infinity}=20^{o}C

Velocity of air flow V=5.5m/s

The film temperature is determined as:

T_{f}=\frac{T_{s}-T_{\infinity}}{2}\\\\=\frac{280-20}{2}\\\\=150^{o}C

from the table, properties of air at 1 atm pressure

At T_{f}=150^{o}C

Thermal conductivity, K = 0.03443 W/m^oC; kinematic viscosity v=2.860 \times 10^{-5} m^2/s; Prandtl number Pr=0.70275

The reynolds number for the flow is determined as:

Re=\frac{VD}{v}\\\\=\frac{5.5 \times(3\times10^{-3})}{2.86\times10^{-5}}\\\\=576.92

sice the obtained reynolds number is less than 2\times10^5, the flow is said to be laminar.

The nusselt number is determined from the relation given by:

Nu_{cyl}= 0.3 + \frac{0.62Re^{0.5}Pr^{\frac{1}{3}}}{[1+(\frac{0.4}{Pr})^{\frac{2}{3}}]^{\frac{1}{4}}}[1+(\frac{Re}{282000})^{\frac{5}{8}}]^{\frac{4}{5}}

Nu_{cyl}= 0.3 + \frac{0.62(576.92)^{0.5}(0.70275)^{\frac{1}{3}}}{[1+(\frac{0.4}{(0.70275)})^{\frac{2}{3}}]^{\frac{1}{4}}}[1+(\frac{576.92}{282000})^{\frac{5}{8}}]^{\frac{4}{5}}\\\\=12.11

The covective heat transfer coefficient is given by:

Nu_{cyl}=\frac{hD}{k}

Rewrite and solve for h

h=\frac{Nu_{cyl}\timesk}{D}\\\\=\frac{12.11\times0.03443}{3\times10^{-3}}\\\\=138.98 W/m^{2}.K

The rate of heat transfer from the wire to the air per meter length is determined from the equation is given by:

Q=hA_{s}(T_{s}-T{\infin})\\\\=h\times(\pi\timesDL)\times(T_{s}-T{\infinity})\\\\=138.92\times(\pi\times3\times10^{-3}\times1)\times(280-20)\\\\=340.42W/m

The rate of heat transfer from the wire to the air per meter length is Q=340.42W/m

6 0
3 years ago
Differentiate between "Threshold and Resolution" with suitable examples.
9966 [12]

Answer:

to make the bace of a building more sturdy

Explanation:

example: the bace of the empire state building is stone very sturdy

6 0
3 years ago
Suppose there are 93 packets entering a queue at the same time. Each packet is of size 4 MiB. The link transmission rate is 1.4
Ghella [55]

Answer:

0.19s

Explanation:

Queueing delay is the time a job waits in a queue before it can be executed. it is the difference in time betwen when the packet data reaches it destination and the time when it was executed.

Queueing delay =(N-1) L /2R

where N = no of packet =93

L = size of packet = 4MB

R = bandwidth = 1.4Gbps = 1×10⁹ bps

4 MB = 4194304 Bytes

(93 - 1)4194304 / 2× 10⁹

queueing delay =192937984 ×10⁻⁹

=0.19s

5 0
3 years ago
Other questions:
  • If a hoist lifts a 4500lb load 30ft in 15s, the power delivered to the load is a) 18.00hp b) 9000hp c) 16.36hp d) None of the ab
    8·1 answer
  • There are four distinct events that occur in the Carnot cycle. Name the events and describe each one.
    15·1 answer
  • Can someone help me on my auto tech worksheet
    13·1 answer
  • A particle is moving along a straight line with an initial velocity of 6 m/s when it is subjected to a deceleration of a- (-1.5v
    8·1 answer
  • Disk A has a mass of 8 kg and an initial angular velocity of 360 rpm clockwise; disk B has a mass of 3.5 kg and is initially at
    5·2 answers
  • Suppose we are given three boxes, Box A contains 20 light bulbs, of which 10 are defective, Box B contains 15 light bulbs, of wh
    12·1 answer
  • In a rack and pinion steering system, what component protects other
    11·2 answers
  • 2. What is the Function of the Camshaft in an Internal Combustion Engine?
    13·1 answer
  • What Forces are involved with roller coasters?
    12·2 answers
  • What do one drop, rockers, and steppers all have in common?.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!