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 class of fire extinguisher is appropriate for a fire involving electrical/energized electrical equipment?
krok68 [10]
The answer would be a C class fire extinguisher. 
6 0
3 years ago
Read 2 more answers
To complete a forensic disk analysis and examination, you need to create a ____.
just olya [345]
<span>To complete a forensic disk analysis and examination, you need to create a </span>report.
8 0
3 years ago
The animation industry is solely reliant on 3-D modeling and 3-D virtualization to create the animated movies in the cinemas.
loris [4]
False it is false people also hand draw stuff
7 0
3 years ago
Convert the algebraic expression below to C++ statement Do not use the pow function. Ans = 5x^2 + 15k + y^-2
kramer

Answer:

The C++ statement for the given algebraic expression 5x^2 + 15k + y^-2 is ( ( 5 * ( x * x ) ) + ( 15 * k ) + ( 1 / ( y * y ) ).

Explanation:

To convert the given algebraic expression 5x^2 + 15k + y^-2 into the C++ statement without using the pow function is:

In the given algebraic expression, there are three expressions combined using the + operator.

The first algebraic expression is 5x^2.

Here, x has a power of 2, and 5 is multiplied by the result of x^2. x having the power of 2 means x is multiplied itself twice. The C++ statement for this algebraic expression is (5 * ( x * x)).

The second algebraic expression is 15k.

Here, 15 is multiplied by k. The C++ statement for this algebraic expression is (15 * k).

The third algebraic expression is y^-2.

Here, x has a power of -2. it means 1/y^{2}.  The C++ statement for this algebraic expression is (1/ (y * y).

The combination of all the three C++ statement is (5 * ( x * x)) + (15 * k) + (1/ (y * y).

7 0
2 years ago
Name three items that currently are enhanced due to the embedded computer technology
ArbitrLikvidat [17]

The three items that can be enhanced due to the embedded computer technology are

Digital cameras

Smart phones

Home appliances

There is a massive list of items that are enhanced due to embedded computer technology. They range from simple systems like calculators, digital cameras, mobile phones, home appliances, to advanced systems like control nuclear power plant systems. All these items mentioned are always set to perform a particular function. They allow integration of various operating systems and are built to take advantage of miniature software or hardware state of electronic devices. Items such as smart phones have been enhanced and designed for power efficiency. They have taken advantage of embedded computing technology and do not come with heavy moving components like fans and huge processors. The same case applies to Digital cameras and Home appliance. Embedded computers in heavy equipment such as a washing machine cannot be compared to computing technology in a digital Panasonic camera.

6 0
3 years ago
Other questions:
  • Write an application that allows a user to enter the names and birth dates of up to 10 friends. Continue to prompt the user for
    6·1 answer
  • Businesses use a fax cover sheet is to _____. provide detailed service and product information make sure message reaches the rig
    14·2 answers
  • The hardware to keep the output data when finished is a
    9·1 answer
  • Consider the following code segment. int[] seq = {3, 1, 8, 4, 2, 5}; for (int k = 1; k &lt; seq.length; k++) { if (seq[k] &gt;=
    5·1 answer
  • Convert the following four unsigned binary numbers to decimal and show your work:
    14·1 answer
  • When reading words using a Scanner object's next method, _________. a. any characters at the beginning of the input that are con
    5·1 answer
  • A disk takes 1 ms per track seek time, and the head is currently on track 70. Assume it takes 5 ms to service a request once the
    10·1 answer
  • Identify the equation that translates Y = In(x) five units down.​
    8·1 answer
  • Write a program which asks the user for their name and age. The program should then print a sentence.
    14·1 answer
  • I’m so lost. which username do i do.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!