Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6882033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:12:13+00:00 2026-05-27T05:12:13+00:00

I wrote a program that asks a person to input a team number (assumming

  • 0

I wrote a program that asks a person to input a team number (assumming 0, 1 or 2) and how many goals the team scored for a certain game. I have two problems. First, the if statement that tries to see if there is a tie is completely ignored and, second, team 2 is always scored as the lowest, middle and highest team in a tie.
I am extremely new to C# so please answer for a newbie:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        public static void updateScores(int x, int myTeam1, int myGoal1, int myTeam2, int myGoal2, int[,] values)
        {
            values[myTeam1, x] = myGoal1;
            values[myTeam2, x] = myGoal2;

        }
        static void Main(string[] args)
        {

            //declare variables and integer array 
            //the different locations are set by default to 0
            int highest;
            int middle;
            int lowest;
            int counter = 0;
            int x;
            int y;
            int z;
            int team1;
            int team2;
            int goals1;
            int goals2;
            int[,] teamsGoalArray = new int[3, 4];

            //get information about teams playing and goals scored
            while (counter <= 2)
            {
        Console.WriteLine("Please enter the first team playing in the {0} game", counter+1);
        team1 = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Please enter the number of goals for the team playing in the {0} game", counter       +1);
        goals1 = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Please enter the second team playing in the {0} game", counter+1);
        team2 = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Please enter the number of goals for the team playing in the {0} game", counter +1);
        goals2 = Convert.ToInt32(Console.ReadLine());
        updateScores(counter, team1, goals1, team2, goals2, teamsGoalArray);
        ++counter;
        }

        int a = teamsGoalArray[0, 1] + teamsGoalArray[0, 2] + teamsGoalArray[0, 3];
        int b = teamsGoalArray[1, 1] + teamsGoalArray[1, 2] + teamsGoalArray[1, 3];
        int c = teamsGoalArray[2, 1] + teamsGoalArray[2, 2] + teamsGoalArray[2, 3];

        if (a == b && a == c && b == c)
        {
            Console.WriteLine("All three teams had a total of {0} goals", a);
        }

        if (a >= b && a >= c)
            {
                highest = a;
                x = 0;
            }

            else
                if (b >= a && b >= c)
                {
                    highest = b;
                    x = 1;
                }
                else
                {
                    highest = c;
                    x = 2;
                }
            Console.WriteLine("Team {0} had the highest score with {1} goals", x, highest);

            if (a < b && a > c || a > b && a < c)
            {
                middle = a;
                y = 0;
            }
            else
                if (b < a && b > c || b > a && b < c)
                {
                    middle = b;
                    y = 1;
                }
                else
                {
                    middle = c;
                    y = 2;
                }
            Console.WriteLine("Team {0} had the middle score with {1} goals", y, middle);

            if (a < b && a < c)
            {
                lowest = a;
                z = 0;
            }
            else
                if (b < a && b < c)
                {
                    lowest = b;
                    z = 1;
                }
                else
                {
                    lowest = c;
                    z = 2;
                }
            Console.WriteLine("Team {0} had the lowest score with {1} goals", z, lowest);
        }
     }



  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:12:14+00:00Added an answer on May 27, 2026 at 5:12 am

    The first problem I see is that when you call updateScores, you pass the value of counter, which will be 0, 1, or 2. So you’re filling teamsGoalArray[team, 0] through teamsGoalArray[team, 2]. But when you’re adding up the scores, you’re adding teamsGoalArray[team, 1] through teamsGoalArray[team, 3]. So you are missing the scores from the first game for each team.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a program that rolls a die with a user-specified number of sides.
I wrote a Python program that acts on a large input file to create
So i had to write a program that asks for a user input (which
I wrote a program that forks some processes with fork(). I want to kill
I wrote a program that accepts and outputs Hebrew (i.e. right-to-left) text. In lieu
I wrote a program that worked as a server. Knowing that accept was blocking
I recently wrote a program that used a simple producer/consumer pattern. It initially had
A while ago, I wrote a program that outputs any localhost or network database
I wrote a little program that solves 49151 sudoku's within an hour for an
I wrote a test program thinking that the address of p1 will be less

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.