3
Answers

everybody to discover the error in this code

hang  pham

hang pham

16y
2.2k
1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class TeamStruct
    {
        struct Team
        {
            public String country;
            public int matchesPlayed;
            public int[] goals;
        }
        static void Main(string[] args)
        {
            Team DemoTeam;
            int totalGoals = 0;
            Console.WriteLine("Input information for the country that plays football: ");
            Console.WriteLine("input country name: ");
            DemoTeam.country = Console.ReadLine();
            Console.WriteLine("input number of matches played : ");
            DemoTeam.matchesPlayed = int.Parse(Console.ReadLine());// tai sao lai phai dung int.parse
            DemoTeam.goals = new int[DemoTeam.matchesPlayed];
            for (int i = 0; i < DemoTeam.matchesPlayed; i++)
            {
                Console.WriteLine("Input no of goals in match{0}", i + 1);
                DemoTeam.goals[i] = int.Parse(Console.ReadLine());
                totalGoals = totalGoals + DemoTeam.goals[i];
            }
            Console.WriteLine("total number of matches played by {0}are{1}", DemoTeam.country, DemoTeam.matchesPlayed);
            Console.WriteLine("total number of goals scored by {0} are {i}", DemoTeam.country, totalGoals);  
        }
    }
}
everybody to discover the error in this code! The last line in this code to have mistake.

Answers (3)