How do I write a code to calculate points earned by a team in a match | Sololearn: Learn to code for FREE!

0

How do I write a code to calculate points earned by a team in a match

Coding issues

7/2/2022 2:43:19 PM

Bencozy

9 Answers

New Answer

+2

Which language are you using ?

+1

Please put the description of the problem and your attempt to can help you

+1

First which Game and do you want to do it by the Game or after the Game?

+1

A code that will calculate the total points of a team that won 18 matches and draw 7 matches of which a win is 3point while a draw is 1point

+1

I can only say how I would do that in c# I would make it Like that. Int wins = Convert.ToInt32(Console.ReadLine()); Int draws = Convert.ToInt32(Console.ReadLine() Int Points; Points = wins*3+draws; Console.WriteLine(Points); //Sample Input: 18, 7 //Output: 61 That would be the simples If you want a Code where you can Just calculate the Matches of after looking it. I would do it Like that: string match = Console.WriteLine(); int Points; foreach(char play in string) { if(play == 'w') Points += 3; else if (play == 'd') Points += 1; else Points += 0; } Console.WriteLine(Points); //Sample Input: wdlwdlww //Output: 14 I make that Like that because it's easy to Always Just write down while you watch the Game.

+1

num_of_won_matches = 18 num_of_draw_matches = 7 point_for_win = 3 point_for_draw = 1 total_points = (num_of_won_matches * point_for_win) + (num_of_draw_matches * point_for_draw ) = (18 * 3) + (7 * 1) = 54 + 7 = 61 This is the solution in Python language Bencozy

0

Python

0

Thank you so much

0

Muhammad