IT WORKS NOW! After reading what everyone had to say I started playing with it some more and reading tips from the site.
*For anyone reading in the future. I was missing some brackets as mentioned in the answers below which I added. I also made the mistake of not checking my if statements. I have it so below where the states have to equal "AL", etc. Which isn't possible, because those are divisions.
Thank you to anyone who can help, formatting is a weak point of mine. All this code needs to do is display all of the info from the arrays for teams in the AL and NL division, along with two columns not in array format. One being a variable showing (wins/total), the other column showing the difference between (run score and run against).
But, I keep getting an error about the input string being wrong. I am a bit unsure on what exactly is wrong.
My first guess is that perhaps, because I don't have the last two columns in array format that this is causing the error. But, I'm not sure if I can just put them in an empty array.
Or, perhaps because when I called the two modules I repeated two of the array names. I did this, because I saw my teacher had done it in an example he showed us in class. However, it doesn't seem to be working this time.
I tried to give as much info as I could without text bombing, I can give any other info if needed.
Woot! Thanks to the info, the error is gone! Sadly, I can't seem to get any of the information from the arrays to show up in columns.
string[] teams = { "Boston Red Sox", "New York Yankees", "Tampa Bay Rays", "Toronto Blue Jays", "Baltimore Orioles",
"Cleveland Indians", "Minnesota Twins", "Kansas City Royals", "Chicago White Sox", "Detroit Tigers", "Houston Astros", "Los Angeles Angels",
"Seattle Mariners", "Texas Rangers", "Oakland Athletics", "Washington Nationals", "Miami Marlins", "Atlanta Braves", "New York Mets", "Philadelphia Phillies",
"Chicago Cubs", "Milwaukee Brewers", "St. Louis Cardinals", "Pittsburgh Pirates", "Cincinnati Reds", "Los Angeles Dodgers", "Arizona Diamondbacks",
"Colorado Rockies", "San Diego Padres", "San Francisco Giants" };
string[] state = { "MA", "NY", "FL", "CN", "MD", "OH", "MN", "MO", "IL", "MI", "TX", "CA", "WA", "TX", "CA", "DC",
"FL", "GA", "NY", "PA", "IL", "WI", "MO", "PA", "OH", "CA", "AZ", "CO", "CA", "CA" };
string[] clinch = { "x", "y", "n", "n", "n", "*", "y", "n", "n", "n", "x", "n", "n", "n", "n", "x", "n", "n",
"n", "n", "x", "n", "n", "n", "n", "*", "y", "y", "n", "n" };
string[] divison = { "ALE", "ALE", "ALE", "ALE", "ALE", "ALC", "ALC", "ALC", "ALC", "ALC", "ALW", "ALW", "ALW", "ALW", "ALW", "NLE", "NLE", "NLE", "NLE", "NLE", "NLC", "NLC", "NLC",
"NLC", "NLC", "NLW", "NLW", "NLW", "NLW", "NLW" };
int[] wins = { 93, 91, 80, 76, 75, 102, 85, 80, 67, 64, 101, 80, 78, 78, 75, 97, 77, 72, 70, 66, 92, 86, 83, 75, 68, 104, 93, 87, 71, 64 };
int[] losses = { 69, 71, 82, 86, 87, 60, 77, 82, 95, 98, 61, 82, 84, 84, 87, 65, 85, 90, 92, 96, 70, 76, 79, 87, 94, 58, 69, 75, 91, 98 };
int[] runsScored = { 785, 858, 694, 693, 743, 818, 815, 702, 706, 735, 896, 710, 750, 799, 739, 819, 778, 732, 735, 690, 822, 732, 761, 668, 753, 770, 812, 824, 604, 639 };
int[] runsAgainst = { 668, 660, 704, 784, 841, 564, 788, 791, 820, 894, 700, 709, 772, 816, 826, 672, 822, 821, 863, 782, 695, 697, 705, 731, 869, 580, 659, 757, 816, 776 };
divNL(teams, state, clinch, divison, wins, losses, runsScored, runsAgainst, wins, losses);
divAL(teams, state, clinch, divison, wins, losses, runsScored, runsAgainst, losses, runsScored);
}
static void divNL(string[] t, string[] state, string[] c, string[] d, int[] w, int[] l, int[] r, int[] s, int[] p, int[] o)
{
// displays all info for NL division
string stateM = "";
double pctWins = 0.0;
double raRS = 0.0;
int win = 0, loss = 0;
int aR = 0, sR = 0;
pctWins = (double)win / (win + loss);
raRS = (double)aR - sR;
Console.WriteLine("All Data for NL Division Teams");
Console.WriteLine("{0,24}{1,18}{2,18}{3,18}{4,18}{5,18}{6,18}{7,18}{8,18}{9,18}", "Team", "State", "Clinch", "Div", "W", "L", "RS", "RA", "WinPCT", "RA/RS");
Console.WriteLine("{0,24}{1,18}{2,18}{3,18}{4,18}{5,18}{6,18}{7,18}{8,18}{9,18}", "----", "-----", "----", "----", "-----", "----", "-----", "----", "-----", "-----");
for (int i = 0; i < state.Length; ++i)
{
if (state[i] == "NLC" | state[i] == "NLW" | state[i] == "NLE")
{
stateM = state[i];
Console.WriteLine("{0,24}{1,18}{2,18}{3,18}{4,18}{5,18}{6,18}{7,18}{8,18}{9,18}", t[i], state[i], c[i], d[i],
w[i], l[i], r[i], s[i], pctWins, raRS);
}
}
}
static void divAL(string[] t, string[] state, string[] c, string[] d, int[] w, int[] l, int[] r, int[] s, int[] p, int[] o)
{
//displays all info for Al divsion
string stateM = "";
double pctWins = 0.0;
double raRS = 0.0;
int win = 0, loss = 0;
int aR = 0, sR = 0;
pctWins = (double)win / (win + loss);
raRS = (double)aR - sR;
Console.WriteLine("\n\nAll Data for AL Division Teams\n");
Console.WriteLine("{0,20}{1,8}{2,8}{3,8}{4,8}{5,8}{6,8}{7,8}{8,8}{9,8}", "Team", "State", "Clinch", "Div", "W", "L", "RS", "RA", "WinPCT", "RA/RS");
Console.WriteLine("{0,20}{1,8}{2,8}{3,8}{4,8}{5,8}{6,8}{7,8}{8,8}{9,8}", "----", "-----", "----", "----", "-----", "----", "-----", "----", "-----", "-----");
for (int i = 0; i < state.Length; ++i)
{
if (state[i] == "ALC" | state[i] == "ALE" | state[i] == "ALE")
{
stateM = state[i];
Console.WriteLine("{0,8}{1,8}{2,8}{3,8}{4,8}{5,8}{6,8}{7,8}{8,8}{9,8}", t[i], state[i], c[i], d[i],
w[i], l[i], r[i], s[i], pctWins, raRS);
}
}
}
You have forgotten some opening curly braces in these lines:
Console.WriteLine("0,24}{1,18}{2,18}{3,18}{4,18}{5,18}{6,18}{7,18}{8,18}{9,18}", "----", "-----", "----",
"----", "-----", "----", "-----", "----", "-----", "-----");
Console.WriteLine("0,24}{1,18}{2,18}{3,18}{4,18}{5,18}{6,18}{7,18}{8,18}{9,18}", t[i], state[i], c[i], d[i],
w[i], l[i], r[i], s[i], pctWins, raRS);
Console.WriteLine("0,24}{1,18}{2,18}{3,18}{4,18}{5,18}{6,18}{7,18}{8,18}{9,18}", "----", "-----", "----",
"----", "-----", "----", "-----", "----", "-----", "-----");
Console.WriteLine("0,24}{1,18}{2,18}{3,18}{4,18}{5,18}{6,18}{7,18}{8,18}{9,18}", t[i], state[i], c[i], d[i],
w[i], l[i], r[i], s[i], pctWins, raRS);
They should be as follow:
Console.WriteLine("{0,24}{1,18}{2,18}{3,18}{4,18}{5,18}{6,18}{7,18}{8,18}{9,18}", "----", "-----", "----",
"----", "-----", "----", "-----", "----", "-----", "-----");
Console.WriteLine("{0,24}{1,18}{2,18}{3,18}{4,18}{5,18}{6,18}{7,18}{8,18}{9,18}", t[i], state[i], c[i], d[i],
w[i], l[i], r[i], s[i], pctWins, raRS);
Console.WriteLine("{0,24}{1,18}{2,18}{3,18}{4,18}{5,18}{6,18}{7,18}{8,18}{9,18}", "----", "-----", "----",
"----", "-----", "----", "-----", "----", "-----", "-----");
Console.WriteLine("{0,24}{1,18}{2,18}{3,18}{4,18}{5,18}{6,18}{7,18}{8,18}{9,18}", t[i], state[i], c[i], d[i],
w[i], l[i], r[i], s[i], pctWins, raRS);
Hint:
Use $""
string format that causes less errors.