When the user types in 'day' the if statement should run and display all the data from the text file, but for some reason it only prints the first line 'Monday' but really it should print:
'Monday Friday Thursday Wednesday Tuesday Monday Friday Thursday Wednesday Tuesday Monday Friday'
How do I fix this?
(Also if the user types, for example, 'day' the else statement still writes how do I fix that?)
static void Main(string[] args)
{
//int ctr = 0;
string[] dayData = File.ReadAllLines("Day.txt");
string[] dateData = File.ReadAllLines("Date.txt");
string[] sh1CloseData = File.ReadAllLines("SH1_Close.txt");
string[] sh1DifferenceData = File.ReadAllLines("SH1_Diff.txt");
string[] sh1OpenData = File.ReadAllLines("SH1_Open.txt");
string[] sh1VolumeData = File.ReadAllLines("SH1_Volume.txt");
Console.WriteLine("Which array would you like to view?");
string input = Console.ReadLine();
if (input.ToLower() == "day")
Console.Write("\n{0}", dayData);
if (input.ToLower() == "date")
Console.Write("\n{0}", dateData);
if (input.ToLower() == "close")
Console.Write("\n{0}", sh1CloseData);
if (input.ToLower() == "difference")
Console.Write("\n{0}", sh1DifferenceData);
if (input.ToLower() == "open")
Console.Write("\n{0}", sh1OpenData);
if (input.ToLower() == "volume")
Console.Write("\n{0}", sh1VolumeData);
else
Console.Write("\nSorry, you entered an invalid term, please enter: day, date, close, difference, open or volume.");
Console.Read();
}
Aucun commentaire:
Enregistrer un commentaire