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]
3 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]3 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
The Recycle Bin exists as a metaphor for throwing files away, but it also allows a user to retrieve and restore files. Once the
Karolina [17]

Answer:

a) INFO2 file

Explanation:

When a file is deleted and moved to the Recycle Bin generates its own records inside a INFO2 file. These files save data from the deleted file, so it can be analyzed later. The size of a INFO2 file is 800 bytes usually.

The data saved into this files is:

  • Original location of the removed file
  • Date and time when deleted
  • Physical size of the deleted file
6 0
3 years ago
A program to add two numbers in C++
Paladinen [302]
I don't know if i understood correctly, but C++ can add numbers by using the + funciton. You could either use:
a = b + c
or
a = a + b
if you want to increment a variable.
7 0
3 years ago
I DON"T GET THIS WHY IS THIS FUNNY
MakcuM [25]

Answer:

They deleted my answer what is funny?

Explanation:

8 0
3 years ago
Write a method called compress that takes a string as input, compresses it using rle, and returns the compressed string. case ma
MaRussiya [10]
<span>public static String compress (String original) { StringBuilder compressed = new StringBuilder(); char letter = 0; int count = 1; for (int i = 0; i < original.length(); i++) { if (letter == original.charAt(i)) { count = count + 1; } else { compressed = count !=1 ? compressed.append(count) : compressed; compressed.append(letter); letter = original.charAt(i); count = 1; } } compressed = count !=1 ? compressed.append(count) : compressed; compressed.append(letter); return compressed.toString(); }</span>
5 0
4 years ago
Given that n refers to a positive int use a while loop to compute the sum of the cubes of the first n counting numbers, and asso
dybincka [34]

Answer:

The program in Python is as follows:

n = int(input("n:"))

total = 0

for k in range(1,n+1):

   total+=k**3

print(total)

Explanation:

This gets input for n

n = int(input("n:"))

This initializes total to 0

total = 0

This iterates from 1 to n

for k in range(1,n+1):

This adds up the cube of each digit

   total+=k**3

This prints the calculated total

print(total)

7 0
3 years ago
Other questions:
  • he function below takes one parameter: a list of strings (string_list). Complete the function to return a new list containing on
    5·2 answers
  • You have an executive who needs her print jobs handled above those of others. how would you accomplish this advanced printing co
    8·1 answer
  • What is the main piece of computer software on which every other piece of software relies?
    15·1 answer
  • How many generations of computer languages
    10·1 answer
  • Playstation network live updates pes 2018 does it cost extra
    13·1 answer
  • How does is make you feel when you're kind to others? What are some opportunities in your life to be more kind to your friends a
    9·1 answer
  • Consider the following high-level recursive procedure: long long int flong long int n, long long int k long long int b b k+2; if
    9·1 answer
  • Are high tech messages are always preferable to low tech messages
    8·1 answer
  • In what situation is a read receipt notification not sent when an email is opened or previewed bya recipient?
    8·2 answers
  • What do you setup when you want to filter traffic from getting through a firewall?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!