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
Students can use eNotes to type notes directly on screen and
zalisa [80]
A. review or print them later
6 0
4 years ago
Read 2 more answers
Does any body like animal jam
cricket20 [7]

Answer:

Never used it so I do not know.

Explanation:

To be honest i thought you meant like animal jelly at first

7 0
4 years ago
Read 2 more answers
What is one benefit of using electronic flash cards?
velikii [3]

Answer:

They can be searched using keywords. they may have a different alarm settings. they provide a personal organizer.

Explanation:

Hope this helped Mark BRAINLIEST!!!

4 0
3 years ago
Read 2 more answers
What determines gravitational pull?<br><br> volume<br><br> mass<br><br> the sun<br><br> acceleration
Arte-miy333 [17]
C. The sun is correct!
8 0
3 years ago
Read 2 more answers
Kyle is running out of disk space on his hard drive on a Windows XP Professional system. He has installed and configured a third
Varvara68 [4.7K]

Answer:

The answer is "Disk utility".

Explanation:

It'll work well go over to Disk utility before updating the drivers like diskmgmt.msc throughout the Running box, or right-click Device icon, and pick Manage. Click Rescan Disks on the key decision-makers. It's not essential to reconnect until the machine recognizes the latest disc.

  • In each disc setup as storage properties is a reactive drive. Almost every dynamic disk is separated into quantities.
  • It is the season, spanned, and strip volume forms will be included.
5 0
3 years ago
Read 2 more answers
Other questions:
  • Write code that prints: usernum ... 2 1 blastoff! your code should contain a for loop. print a newline after each number and aft
    12·1 answer
  • Write the statements needed so that the variable secondWord is associated with the second word of the value of sentence . So, if
    13·1 answer
  • During a night flight, you observe a steady red light and a flashing red light ahead and at the same altitude. What is the gener
    11·1 answer
  • What is the difference between a design pattern and a DLL?
    12·1 answer
  • Why computer is known as data processing system?
    14·1 answer
  • Users of an access point share the transmission capacity of the access point. The throughput a user gets is called the ________.
    11·1 answer
  • In programming, what is a string?
    8·2 answers
  • When referring to hard drives, access time is measured in
    11·1 answer
  • Why would you browse by entering a URL rather than use a link in a Web page
    15·1 answer
  • What is an example of work performed by an integration platform as a service (ipaas)?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!