using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; namespace Q2_VisualisingGraphs_V1 { internal class Program { static void Main(string[] args) { //Declare variables int scaleX = 10; int scaleY = 5; int[,] coords = { {0, 0}, {1, 1}, {2, 2}, {3, 2}, {4, 1}, {5, 0}, {6, -1}, {7, -2}, {8, -2}, {9, -1}, {10, 0} }; for (int y = scaleY; y >= -scaleY; y--) { Console.Write(y.ToString().PadLeft(2) + "|"); if (y == 0) { //Write the x axis Console.Write("+"); for (int x = 0; x < scaleX; x++) { Console.Write("-"); } Console.WriteLine("-"); } //Loop to check for points for (int x = 0; x <= scaleX; x++) { //If y = 0 don't plot as the x axis causes issues if (y == 0) { Console.Write(" "); continue; } //Check if the coordinate is in the array bool isPointPlotted = false; for (int i = 1; i < coords.GetLength(0); i++) { if (coords[i, 0] == x && coords[i, 1] == y) { isPointPlotted = true; break; } } //If the point is correct place an x else leave empty if (isPointPlotted) { Console.Write("x"); } else { Console.Write(" "); } } Console.WriteLine(); } //Keep the program open Console.ReadLine(); } } } //Really struggled on this part so I rewrote the whole program as my old approach was confusing me