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
Wewaii [24]
3 years ago
12

Write a program that records high-score data for a fictitious game. the program will ask the user to enter five names, and five

scores. it will store the data in memory, and print it back out sorted by score. the output from your program should look approximately like this: enter the name for score #1: suzy enter the score for score #1: 600 enter the name for score #2: kim enter the score for score #2: 9900 enter the name for score #3: bob enter the score for score #3: 1012 enter the name for score #4: armando enter the score for score #4: 8000 enter the name for score #5: tim enter the score for score #5: 514
Computers and Technology
1 answer:
Harman [31]3 years ago
3 0

Scores.cpp

#include <iostream>

#include <string>

using namespace std;

void initializeArrays(string names[], int scores[], int size);

void sortData(string names[], int scores[], int size);

void displayData(const string names[], const int scores[], int size);

int main()

{

   string names[5];

   int scores[5];

   //reading names and scores

   initializeArrays(names, scores, 5);

   //sorting the lists based on score.

   sortData(names, scores, 5);

   //displaying the contents of both arrays

   displayData(names, scores, 5);

 

  return 0;

}

void initializeArrays(string names[], int scores[], int size){

   for(int i=0; i<size; i++){

       cout<<"Enter the name for score #"<<(i+1)<<": ";

       cin >> names[i];

       cout<<"Enter the score for score #"<<(i+1)<<": ";

       cin >> scores[i];

       }

}

void sortData(string names[], int scores[], int size){

   

       int temp = 0;

       string tempStr = "";

       

       for(int i=0; i < size; i++){

               for(int j=1; j < (size-i); j++){

                      //checking max score and sorting based on it.

                       if(scores[j-1]< scores[j]){

                               //swap the elements!

                           //swapping scores

                               temp = scores[j-1];

                               scores[j-1] = scores[j];

                               scores[j]=temp;

                               

                               //swapping names

                               tempStr = names[j-1];

                               names[j-1] = names[j];

                               names[j]=tempStr;

                       }

                       

               }

       }

}

void displayData(const string names[], const int scores[], int size){

   cout<<"Top Scorers:"<<endl;

       //printing the elements up to the size of both arrays.

       for(int i=0; i<size; i++){

           cout<<names[i]<<": "<<scores[i]<<endl;

       }

}

You might be interested in
Which of the following is considered to be intellectual property?
ad-work [718]

The answer is actually A. I took the test and selected the wrong answer, but A was the one the test said was right. Plz mark brainliest!!! Hope this helped! ;^)

4 0
2 years ago
How do you close a file?
natita [175]
You gave the answer in your question
8 0
3 years ago
Read 2 more answers
A report has a column of totals, with each total adding to the cell above it. What kind of calculated figure is this?
Alexxx [7]

ANSWER:

The correct answer is Running Sum.

Explanation:

A report has a column of totals, with each total adding to the cell above it. Such type of calculated figure is called the Running Sum.

Running sum is also called the Partial Sum. In such type of summation, the values in the sequence is added to get a final result and then if a new number comes, it is again added to the grand sum, and in this way the sequence continues. Every new entry is added to the previous sum to get another sum.

3 0
3 years ago
Sue conducted an experiment to determine which paper towel is the most absorbent among three different brands. She decides to pr
Triss [41]

Answer:

Its C

Explanation:

On Edg

7 0
3 years ago
You discover that the lecturers will be using the laptops for online and video lecturing, and you see the need to upgrade the RA
Step2247 [10]

The RAM of G.Skill Trident Z Neo 3600 will be highly recommended for online and video lecturing.

<h3>What is RAM?</h3>

This is referred to random access memory and store information which can be retrieved quickly.

The RAM of G.Skill Trident Z Neo 3600 is 32GB which ensures the speed of the processor is fast.

Read more about RAM here brainly.com/question/13748829

#SPJ9

7 0
1 year ago
Read 2 more answers
Other questions:
  • )1-bit sign, 8-bit exponent, 23-bit fraction and a bias of127 is used for ___________ Binary Floating PointRepresentation
    11·1 answer
  • What is the difference between primary storage,secondary storage and offline storage what type of storage can be
    6·2 answers
  • How are logical operators used?
    14·1 answer
  • Which of the following is a computerized job classification system that contains continually updated information regarding the k
    15·1 answer
  • What is copy and paste?
    13·2 answers
  • The words that follow a code number in the cpt manual are called the
    12·1 answer
  • Different search engines available on the internet​
    7·1 answer
  • Which feature of REPL.it would you use to transmit your program to a friend?
    12·1 answer
  • I need some help-
    15·1 answer
  • Hi everyone can anyone tell me how to align the photo the right in code.org
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!