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
olga nikolaevna [1]
3 years ago
10

(Apply) Students will write a function and loop to iterate until a condition is met LO: (Analyze) Students will identify edge ca

ses from a problem statement. In this game of volleyball, two teams compete to be the first team to score 21 points. However, to win the game, a team must also lead by two points. For example, if team A is tied with team B (20-20) and then scores, they will only be ahead by one point (21-20). Then, if team B scores a point, the game will be tied again (21-21). Then, if either team can score two consecutive points, they will win. Write a program that reads data about volleyball matches from standard input and then determines the outcome of the game. If the input word is "A" it means that team A scored a point. If the input word is "B" it means that team B scored a point. If the input word is "end" it means that the game ended. Write a function that can be used in a loop as part of the condition. It should evaluate if either team is a winner. Call the function weHaveAWinner. In main, calculate the scores and announce the team that won or that the game was a draw. Display the game result in this format:
Team A won! (21-14)
Game ended as a draw. (21-21)
#include
using namespace std;
/*
* Determines the outcome of a volleyball game.
*/
int main() {
return 0;
}
Computers and Technology
1 answer:
Setler79 [48]3 years ago
8 0

Answer:

The program is as follows:

#include<iostream>

using namespace std;

void weHaveAWinner(int A, int B){

   if(A-2>=B){

       cout<<"Team A won! ("<<A<<"-"<<B<<")";    }

   else if(B-2>=A){

       cout<<"Team B won! ("<<A<<"-"<<B<<")";}

   else if(B == A){

       cout<<"Game ended as a draw. ("<<A<<"-"<<B<<")";}

   else{

       cout<<"Team A: "<<A<<" - Team B: "<<B;}

}

int main() {

   int teamA = 0;    int teamB = 0;

   string score;

   cout<<"Score: "; cin>>score;

   while(score != "end"){

       if(score == "A"){

           teamA++;}

       else if(score == "B"){

           teamB++;}

       cout<<"Score: "; cin>>score;

   }

   weHaveAWinner(teamA,teamB);

   

return 0;

}

Explanation:

This defines the weHaveAWinner function, which receives the scores of both teams as its parameters  

void weHaveAWinner(int A, int B){

This checks if team A score at least 2 more than team B. If yes, it declares team A the winner

<em>    if(A-2>=B){ </em>

<em>        cout<<"Team A won! ("<<A<<"-"<<B<<")";    } </em>

This checks if team B score at least 2 more than team A. If yes, it declares team B the winner

<em>    else if(B-2>=A){ </em>

<em>        cout<<"Team B won! ("<<A<<"-"<<B<<")";} </em>

This checks for a draw

<em>    else if(B == A){ </em>

<em>        cout<<"Game ended as a draw. ("<<A<<"-"<<B<<")";} </em>

This checks if both team are within 1 point of one another  

<em>  else{ </em>

<em>        cout<<"Team A: "<<A<<" - Team B: "<<B;} </em>

<em>} </em>

The main begins here

int main() {

This declares and initializes the score of both teams to 0

   int teamA = 0;    int teamB = 0;

This declares score as string

   string score;

This prompts the user for score

   cout<<"Score: "; cin>>score;

This loop is repeated until the user inputs "end" for score

   while(score != "end"){

If score is A, then teamA' score is incremented by 1

<em>        if(score == "A"){ </em>

<em>            teamA++;} </em>

If score is B, then teamB' score is incremented by 1

<em>        else if(score == "B"){ </em>

<em>            teamB++;}</em>

This prompts the user for score<em> </em>

       cout<<"Score: "; cin>>score;

   }

This calls the weHaveAWinner function at the end of the loop

   weHaveAWinner(teamA,teamB);

You might be interested in
Five aplications of ict​
Irina18 [472]

Answer:

MS Word, MS Excel, MS PowerPoint, Adobe Photoshop, Adobe Reader

Explanation:

8 0
3 years ago
When applying a filter to a text layer, how can you ensure that the types editability is not lost
yarga [219]

Answer:

Convert the layer into a smart object.

Explanation:

7 0
4 years ago
Microsoft Paint can be described as a digital sketch pad ?
alexira [117]
Yes I can be be a digital sketch pad

HOPE THIS HELPS!!!!!!!
4 0
3 years ago
Is a web-based architectural approach in which users interact via a web browser or other web-enabled view layer with application
katrin2010 [14]
Hi,

Yes to include real-time interaction between users on website you need more than just raw HTML and CSS. You would need functionality so include JS or .NET framework (C# or VB), you could also add Python, but most of all in order to control user information: Database.

Hope this helps.
r3t40
7 0
3 years ago
Convert the following decimal numbers into binary numbers. <br><br>pls ASAP<br>​
Anna007 [38]

Explanation:

Given, the cost price of the TV is Rs 24600. Now, the cooler costs Rs 800 more than one-third of the TV. The cost price of the cooler is Rs 9000.

6 0
3 years ago
Other questions:
  • A small company has developed a specialized software product that it configures specially for each customer. New customers usual
    14·1 answer
  • 6. When should you return to the right lane after passing another car on the left?
    14·2 answers
  • What is the keyboard shortcut for the Undo command?
    8·1 answer
  • What are some of the other operations that might be implemented for a queue?
    14·1 answer
  • How is an image represented
    15·2 answers
  • A programmer is writing a system that is intended to be able to store large amounts of personal data. As the programmer develops
    11·1 answer
  • The activities that gather information about the organization and its network activities and assets is called fingerprinting. __
    14·1 answer
  • Which of the following describes why graphical interfaces quickly became popular after their introduction to the mass market?
    5·1 answer
  • In your own words, how are sources of income and expenses related to
    12·2 answers
  • Explain the application software and utility software in detail​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!