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
ehidna [41]
3 years ago
10

A basketball game has four quarters. Write a program to do the following. Use a for loop to input scores of team A and team B in

each of the four quarters. Every time a score is entered, update and display the current total score of that team. After all four quarters, compare the total scores of the two teams and display the outcome of the game (“Team A has won”, “Team B has won” or “It is a tie”)
Enter team A score in this quarter: 22
Team A score so far: 22
Enter team B score in this quarter: 24
Team B score so far: 24
Enter team A score in this quarter: 19
Team A score so far: 41
Enter team B score in this quarter: 26
Team B score so far: 50
Enter team A score in this quarter: 25
Team A score so far: 66
Enter team B score in this quarter: 22
Team B score so far: 72
Enter team A score in this quarter: 21
Team A score so far: 87
Enter team B score in this quarter: 20
Team B score so far: 92
Team B has won

Enter team A score in this quarter: 22
Team A score so far: 22
Enter team B score in this quarter: 20
Team B score so far: 20
Enter team A score in this quarter: 26
Team A score so far: 48
Enter team B score in this quarter: 21
Team B score so far: 41
Enter team A score in this quarter: 19
Team A score so far: 67
Enter team B score in this quarter: 28
Team B score so far: 69
Enter team A score in this quarter: 25
Team A score so far: 92
Enter team B score in this quarter: 23
Team B score so far: 92
It is a tie

Computers and Technology
1 answer:
Ronch [10]3 years ago
4 0

Answer:

The program in cpp for the given scenario is shown.

#include <iostream>

using namespace std;

int main()

{

   //variables declared to hold individual and total scores

   int score_a=0, a;

   int score_b=0, b;

   //user input taken for score

   for(int i=0; i<4; i++)

   {

       std::cout << "Enter team A score in quarter " <<(i+1)<<" : ";

       cin>>a;

       score_a = score_a+a;

       std::cout << "Team A score so far: "<< score_a <<std::endl;

       std::cout << "Enter team B score in quarter " <<(i+1)<<" : ";

       cin>>b;

       score_b = score_b+b;

       std::cout << "Team B score so far: "<< score_b <<std::endl;

   }

   //winner team decided by comparing scores

   if(score_a>score_b)

       std::cout << "Team A has won" << std::endl;

   if(score_a==score_b)

       std::cout << "It is a tie." << std::endl;

   if(score_a<score_b)

       std::cout << "Team B has won" << std::endl;

   //program ends

   return 0;

}

Explanation:

1. The integer variables are declared to hold both individual scores and the total score for both the teams.

   int score_a=0, a;

   int score_b=0, b;

2. The variables to hold total scores are initialized to 0.

3. Inside for loop, scores for both teams for all 4 quarters are taken from the user.

4. Inside the same for loop, a running total for the score of each team is computed and displayed.

score_a = score_a+a;

score_b = score_b+b;

5. Outside the loop, the total scores of both the teams are compared and the winner team is displayed. This is done using multiple if statements.

if(score_a>score_b)

       std::cout << "Team A has won" << std::endl;

   if(score_a==score_b)

       std::cout << "It is a tie." << std::endl;

   if(score_a<score_b)

       std::cout << "Team B has won" << std::endl;

6. After each message is displayed, a new line is inserted at the end using keyword, endl.

7. The program ends with a return statement.

8. The whole code is written inside main(). In cpp, it is not mandatory to write the code inside a class since cpp is not a purely object-oriented language.

9. The output is attached in an image.

You might be interested in
How Extreme Programming addresses Software Testing andevolution ?
kumpel [21]

Answer:

Extreme programming is a software development technique which is used to enhance software quality and it's response to ever changing customer requirements.

Testing

Testing is main focus in extreme programming.Extreme programming addresses testing in a way that if a minute testing can eliminate a bit of flaws, extensive testing can terminate a lot of flaws.

Evolution in Extreme programming is like this:-

Coding:-First programmers will code the problem.

Testing :- Testing is done to remove flaws.

Listening:- Programmers must listen to the customers to what they need.

Designing:-Then design according to the customer needs.

6 0
3 years ago
Why do people on Brainly verify answers that are wrong. I got 90% and 80% percent on my tests because of it
Bezzdna [24]
I feel that, you can’t trust it.
3 0
3 years ago
Read 2 more answers
Why is stranded rather than solid cable used for patch cables? Why is it critical not to score the jacket too deeply when stripp
Serggg [28]

Answer:

The definition of the issues is listed throughout the section down.

Explanation:

  1. Stranded cables are somewhat more compact and can be mounted quickly. Strong cables become rigid in design, and they are not versatile for installation. In comparison with solid connectors, amplification is indeed high.
  2. Unless the innermost layer including its wire is broken as we attempt to connect the cable, it will not function. So, whenever stripping the cables through the walls, it's indeed important not to rank the jack too profoundly.
  3. It would be quick to untwist the cable and then will ensure that perhaps the connection is appropriate for the most widely encountered rj-45 connection whenever the wiring of 0.5 inches becomes coupled up.
  4. If we don't keep the right pin colors in order, the relation won't work. Afterward, when another connexon is broken due to many complications, it would be impossible to figure out the contacts unless the pins coloring are not always in sequence.
  5. The connection pairs can be cut off through 0.5 inches within about therefore the gap within the connector is narrower and the wire would not be correctly attached if we break the cable further. The link is lost and the cable does not run properly.
  6. It is necessary to ensure that perhaps the wires are forced to the end of the platform since the connexon will indeed be broken as well as the connector would not operate unless the wires aren't moved. The wires will fall out of another socket as well.
  7. Before even being incorporated into another crimping unit, it is good to carefully check the connection sequence to ensure that perhaps the wires are to the end since it is impossible to verify the sequence until the wires are attached to something like the connector. Unless the connections are not always in alignment, the link will also not be provided and indeed the wire would not operate correctly, even if the link is provided. Such wires can also be presented to use load barriers, and that it's the simplest operation.
  8. The Durability Tester has been used to determine the hardness between two stages, whereas the connection efficiency is tested using the qualification tester.

8 0
3 years ago
Write a paper of at least 300 words that includes:
Marina86 [1]

Answer:Let’s start with a review of the essential steps in the career planning process.

Career Planning

Shepard and Mani define career planning “as an ongoing process through which an individual sets career goals and identifies the means to achieve them” (2013, p. 14). It is through career planning that a person evaluates abilities and interests, assesses values and personality, considers alternative career opportunities, establishes career goals, and plans practical developmental activities.

Career planning requires individuals to understand themselves and their values, interests, and skills. It is also an ongoing process, one that must be repeated with changes in employment and life circumstances. As you gain more experience and knowledge, the process will begin anew.

This section reviews the five essential steps of career planning, which are based on our research and input from industry experts:

Conduct a self-assessment

Research the labour market

Create your career search toolkit

Put your career campaign into action

Engage in networking

Let’s start at step one.

Step One: Conduct a Self-Assessment

Self knowledge is the key to choosing a career. It can be overwhelming to begin the process of self-assessment. However, if done well at the start, the likelihood of securing work that has meaning, purpose, and fulfillment is far greater. Understanding your preferences, knowing your strengths, and honestly facing the areas you need to develop are the first steps for effective self-assessment.

Explanation:

7 0
3 years ago
PLEASE HELP!!! WILLGIVE BRAINLIEST!!!
morpeh [17]
Black absorbs all visible parts of the spectrum turning that light energy into heat. The more it absorbs the more heat it emits.
4 0
4 years ago
Read 2 more answers
Other questions:
  • (If the link is not working, search for "Veritasium Levitating Barbecue". At approximately the 2 minute mark, the screen shows 8
    9·1 answer
  • ____ are commonly used for communication between OS components, for queuing requests to an OS service, and for exchanging messag
    5·2 answers
  • If you don't know whether to write too, two, or to, you should use the spell-checker to help you decide. true or false?
    7·1 answer
  • (1) In Tamara's science class, the students are learning Which sentence shows an action that is extrinsically
    7·1 answer
  • Which method can help you prevent RSI while using a keyboard?
    14·1 answer
  • What symbol precedes all structured references in formula autocomplete lists?
    15·1 answer
  • Defensive programming is sometimes referred to as _________.
    5·1 answer
  • A serial schedule:
    8·1 answer
  • How many passes will it take to find 30 using a binary search?
    6·1 answer
  • Moving images of real event​
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!