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]
4 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]4 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
1. provides a list of at least five SSIDs and the
taurus [48]

One of the most important ways to provide wireless security is through:

  • The use of encryption.

<h3>What is Wireless Security?</h3>

This refers to the network authentication and use of encryption to secure a network from unauthorized access or compromise of the network by an external agent.

With this in mind, we can see that SSID is a WiFi network name and it makes use of WPA2 security encryption to protect the wireless network through wireless encryption protocol.

Please note that your question is incomplete so I gave you a general overview to help you get a better understanding of the concept.

Read more about wireless security here:
brainly.com/question/14449935

8 0
2 years ago
When it comes to paying bills at restaurants, Wallace always leaves a 15% tip based on the pretax price. However, Wallace is tir
tatuchka [14]

Answer:

where are the answers.

Explanation:

8 0
3 years ago
Difference between array processor and vector processor​
Gala2k [10]

Answer:

An array is used for the storaging the paticular given size element that is either fixed or given by the user. However an vector is also used for storing purpose but the size of the table is assign automatically during the running time of the program or we say dynamic size assign to table.

5 0
3 years ago
Read 2 more answers
Hubs hardware advantage's and disadvantages​
marin [14]

Answer:

answer in picture

hope it's helpful

6 0
3 years ago
A(n) _____ chart is drawn on the same worksheet as the data.
svet-max [94.6K]
A is the answer because it makes more sense.............
5 0
3 years ago
Other questions:
  • Which of these expressions is used to check whether num is equal to value?
    12·1 answer
  • write code to declare variables for s0 with a value of 12.0, v0 with a value of 3.5, a with a value of 9.8, and t with a value o
    13·1 answer
  • How can an installation be a tool for community building?
    9·1 answer
  • A(n) ______________________________ is a camera mount that uses the concept of a lever and fulcrum and allows a camera to be rai
    9·1 answer
  • __ provides an integrated development environment (IDE) for rapidly developing Java programs. Editing, compiling, building, debu
    15·1 answer
  • Why do designers use tonal shading?
    10·2 answers
  • Design the program that reads two files and compares their contents. The program calls a method that reads the file one line at
    10·1 answer
  • My laptop volume has got really low all of a sudden. It wasn't the best to start with but now i can barely even hear it at 100%.
    10·1 answer
  • I can talk to you! How about we talk through the you know where people comment and say stuff about the question1
    10·2 answers
  • You notice a growing number of devices, such as environmental control systems and wearable devices, are connecting to your netwo
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!