Computer Science, asked by kiara373, 2 months ago

Scenario :

Bill, Tommy and Daisy are playing basket ball. Bill's father is capturing the score. Each player gets 2 chances.

Requirement :

1. Prompt the user to input the player's name who scored the basket.

If a player is not scoring in his/her chance, enter a space.

Example:

2 chance for each player so 6 rounds.

Bill

Tommy
Tommy
Daisy
Daisy

2. Calculate each player's basket scored based on the given condition.
Scoring Condition:
Bill's father records the basket scorer's name. Each basket gives the player 1 point.

If any player is scoring continuous basket , then they will get one bonus point.

For example, if Bill baskets 1st and 2nd consecutively, he gets a bonus point (which means, he gets 3 points)

Important : Follow the same case for Bill, Daisy and Tommy. 'B', 'D', 'T' capitals.

Sample Input/Output

Sample Input 1:

Player Name : Daisy
Player Name: Daisy
Player Name : Bill
Player Name : Bill
Player Name : Tommy


Sample output :

Bill Score : 3
Tommy Score : 1
Daisy Score : 3

Sample Input 2:

Player Name : Tommy
Player Name : Bill
Player Name : Bill
Player Name : Daisy

Player Name : Tommy

Sample output :
Bill Score : 3
Tommy Score : 2
Daisy Score : 1

Sample Input 3:

Player Name : Bill
Player Name : Bill
Player Name : Daisy
Player Name : Daisy
Player Name : Tommy
Player Name : Tommy

Sample Output :

Bill Score : 3
Tommy Score : 3
Daisy Score : 3

Answers

Answered by mousumigarai82077
0

Answer:

All wins.

Explanation:

They all score three points.

Answered by shivic58sl
0

Answer:

The code would be:

Explanation:

Program Class

{

   static void Main()

   {

       Dictionary<string,int> players = new Dictionary<string,int>();

       players.Add("Bill",0);

       players.Add("Tommy",0);

       players.Add("Daisy",0);

       string previous = "";

       for (int n = 0; n < 6; n++)

       {

           Console.Write("Player Name : ");

           string player = Console.ReadLine();

           if (!string.IsNullOrEmpty(player) && player != " ")

           {

               players[player]++;

               if (player.Equals(previous))

                   players[player]++;

               previous = player;

           }

       }

       foreach (KeyValuePair<string, int> kvp in players)

       {

           Console.WriteLine($"Player: {kvp.Key} scored {kvp.Value} baskets");

       }

   }

}

#SPJ2

Similar questions