Here is what I wrote so far,
but it's not working for some reason, and I am getting an error called "unreachable code detected" on Console.Write("press Enter to continue");
Halp~~ QQQQ
static void Main(string[] args)
{
//menu
Console.WriteLine("<
Console.WriteLine("1 - Celsius (C) to Fahrenheit (F)");
Console.WriteLine("2 - Fahrenheit (F) to Celsius (C)");
Console.WriteLine("Q - Quit\n");
Console.Write("Choose (1, 2, or Q):");
//User input
string optionChoice = Console.ReadLine();
optionChoice = Console.ReadLine();
switch (optionChoice)
{
case "1":
Console.WriteLine("Celsius (C) to Fahrenheit (F)");
break;
case "2":
Console.WriteLine("Fahrenheit (F) to Celsius (C)");
break;
case "Q":
case "q":
Console.WriteLine("Bye bye~");
break;
default:
Console.WriteLine("{0} is not valid", optionChoice);
break;
Console.Write("press Enter to continue"); //Where error is
Console.ReadLine();
{
while (optionChoice != "Q" && optionChoice != "q") ;
}
}
VulpesPosted Sep 20, 2014, 3:30 PM
Chisato NPosted Sep 23, 2014, 9:26 AM
It's working well :)
VulpesPosted Sep 20, 2014, 5:18 PM
However, I would place the code for the conversions in separate methods within that class as this will make your program easier to follow.
I've done one of the conversions to show you what I mean:
Chisato NPosted Sep 20, 2014, 4:45 PM
Thank you.
I also have an additional question.
So, if I want to continue on that program to "Celsius (C) to Fahrenheit (F)" and "Fahrenheit (F) to Celsius (C)", do I just continue writing on the same class?
Dipankar BiswasPosted Sep 20, 2014, 3:24 PM
>Console.WriteLine("Not working!!!");
is not being reached because you're returning out of the function just prior to it with:
>return avgChars;
Obviously returning exits the code block
see more..
https://answers.yahoo.com/question/index?qid=20120120002605AAJNIuN