0
How do I write a code to calculate points earned by a team in a match
Coding issues
9 odpowiedzi
+ 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.
0
Thank you so much