I was hoping to get some input on if this C# code is correct or if I need to fix
ID: 671585 • Letter: I
Question
I was hoping to get some input on if this C# code is correct or if I need to fix somethings, any information would be greatly apreciated
class Program
{
static void Main(string[] args)
{
char guessedletter1 = 's';
Char guessedletter2 = 't';
Char guessedletter3 = 'i';
char guessedletter4 = 'n';
char guessedletter5 = 's';
Char guessedletter6 = 'o';
Char guessedletter7 = 'n';
Char Input;
WelcomeMessage();
Input = GetInput();
Input = GetInput();
Input = GetInput();
Input = GetInput();
Input = GetInput();
Input = GetInput();
Input = GetInput();
Console.WriteLine("");
Console.Write("Press any key to continue...");
Console.ReadKey();
}
private static char GetInput()
{
Console.Write("Enter a letter please: ");
ConsoleKeyInfo ckInfo = Console.ReadKey();
Console.WriteLine("");
return ckInfo.KeyChar;
}
private static void WelcomeMessage()
{
Console.WriteLine("************************************************************");
Console.WriteLine("*********************** WEEK 4 *****************************");
Console.WriteLine("************************************************************");
Console.WriteLine("");
}
}
}
Explanation / Answer
using System.IO;
using System;
class Program
{
static void Main(string[] args)
{
char guessedletter1 = 's';
char guessedletter2 = 't';
char guessedletter3 = 'i';
char guessedletter4 = 'n';
char guessedletter5 = 's';
char guessedletter6 = 'o';
char guessedletter7 = 'n';
char Input;
WelcomeMessage();
Input = GetInput();
Input = GetInput();
Input = GetInput();
Input = GetInput();
Input = GetInput();
Input = GetInput();
Input = GetInput();
Console.WriteLine("");
Console.Write("Press any key to continue...");
Console.ReadKey();
}
private static char GetInput()
{
Console.Write("Enter a letter please: ");
ConsoleKeyInfo ckInfo = Console.ReadKey();
Console.WriteLine("");
return ckInfo.KeyChar;
}
private static void WelcomeMessage()
{
Console.WriteLine("************************************************************");
Console.WriteLine("*********************** WEEK 4 *****************************");
Console.WriteLine("************************************************************");
Console.WriteLine("");
}
}
I removed one the extra braces and made Char to char
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.