It looks like you're new here. If you want to get involved, click one of these buttons!
I have a program that works as intended with the but it closes out if there is a "invalid number " inputted. The program should allow the user to input a number between 1 - 50 and produce a message if the number inputted is higher than 50. The program will display the message but then closes out right after. Can anyone take a look and see what I am doing wrong. Using Visual Studio Community edition / Console.App (.NET Freamework.
static void Main(string args)
// loop that continues until the user enters a number < 1 or > 50
// input a whole number
Console.Write("Enter a whole number between 1 and 50: ");
count = Convert.ToInt32(Console.ReadLine());
// check if user wants to exit
if (count >= 1 && count <= 50)
// loop to display count number of asterisks
for (int i = 0; i < count; i++)
Console.WriteLine(); // display a new line at the end
else if (count > 50)
Console.WriteLine("Invalid number, please enter a number between 1-50 only");
while (count > 0 && count <= 50);