0

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

Coding issues

2nd Jul 2022, 2:43 PM
Bencozy
Bencozy - avatar
9 Respuestas
+ 2
Which language are you using ?
2nd Jul 2022, 10:48 PM
Munezero Olivier Hugue
Munezero Olivier Hugue - avatar
+ 1
Please put the description of the problem and your attempt to can help you
2nd Jul 2022, 3:10 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 1
First which Game and do you want to do it by the Game or after the Game?
2nd Jul 2022, 3:40 PM
Felix Alcor
Felix Alcor - avatar
+ 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
2nd Jul 2022, 9:48 PM
Bencozy
Bencozy - avatar
+ 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.
2nd Jul 2022, 10:56 PM
Felix Alcor
Felix Alcor - avatar
+ 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
3rd Jul 2022, 9:28 AM
Muhammad Galhoum
Muhammad Galhoum - avatar
3rd Jul 2022, 7:06 AM
Bencozy
Bencozy - avatar
0
Thank you so much
10th Jul 2022, 6:51 AM
Bencozy
Bencozy - avatar
10th Jul 2022, 6:51 AM
Bencozy
Bencozy - avatar