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
How do i get around goguardian from a chromebook
Dafna11 [192]

Answer:

Navigate to your GoGuardian Classroom.

Click the Students tab.

Click the X icon to the right of the student's name.

Confirm by selecting Remove Student from the popup.

Explanation:

GoGuardian Off-campus filtering. Even after class, students still need access to the best learning tools for their education. ... Using Google's Admin Console and Chrome OS, GoGuardian is able to offer its complete Chromebook filtering and monitoring software wherever the device may be.

3 0
3 years ago
16
Lubov Fominskaja [6]
16
is a built-in mathematical formula included in MS Excel,
A) Function
4 0
3 years ago
The operating system is loaded into memory during the ____ process
Svet_ta [14]
Installation process

8 0
3 years ago
What button is used for paragraph alignment on Microsoft 2016?
Margarita [4]
Just click the buttons on the Paragraph tab on Home.
6 0
3 years ago
You replaced the LCD panel in a laptop computer and verified full system functionality, including wireless connectivity. The cus
Degger [83]

Answer:

There was a mistake in the question. The question included a possible answer. I agreed with the answer given and provide an explanation why I agreed with the answer given.

ANSWER: The laptop's wireless radio is toggled to the off position

Explanation:

Since the laptop technician has verified full system functionality before the customer picked up the item then the problem is likely a setting issue. For the technician to test the wireless connectivity and was satisfied, it means the wireless LAN card was installed and the antennas are working to verify there are no hardware issues. The correct device driver must have been installed as well. Since other users can connect to the WAP it means it is not an external problem. All that is left to check is if the wireless radio is ON or OFF. The customer must have mistakenly toggled the wireless radio OFF and he needs to turn it on in other to connect to the Wireless Access Point.

3 0
3 years ago
Other questions:
  • Create and apply a css class named bigblue, which selects a large, blue-colored font.
    11·1 answer
  • How do you do this question?
    7·1 answer
  • What is constructive criticism?
    5·1 answer
  • When a workforce scheduling problems is formulated as an integer programming model, it has:?
    6·1 answer
  • When you are working in Performance Monitor, in the "Add Counters" dialog box, and need more information about a particular coun
    8·1 answer
  • Consider an array inarr containing atleast two non-zero unique positive integers. Identify and print, outnum, the number of uniq
    10·1 answer
  • If a filesystem has a block size of 4096 bytes, this means that a file comprised of only one byte will still use 4096 bytes of s
    12·1 answer
  • Computer network reduces the cost. explain the statement with example.​
    8·1 answer
  • Electrical data suitable for transmission is called a(n)
    5·1 answer
  • Given two objects represented by the tuples (22, 1, 42, 10) and (20, 0, 36, 8):
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!