ThisIan
ThisIan
CC#
Created by ThisIan on 12/27/2022 in #help
❔ Can not figure out a way to make my code repeat until you type a valid input
im having a hard time figuring out how to make my code repeat until you enter a number and if you enter a letter or some other character it will just repeat itself im also kinda new to this so please dont butcher me
namespace CSLearning
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter your type of equation(+, -, *, /): ");
string typeOfEquation = Console.ReadLine();
if (typeOfEquation.Contains('+'))
{
double num1 = 0;
double num2 = 0;
Console.Write("Enter your first adden: ");
string adden1 = Console.ReadLine();
Console.Write("Enter your second adden: ");
string adden2 = Console.ReadLine();
num1 = Convert.ToDouble(adden1);
num2 = Convert.ToDouble(adden2);
Console.WriteLine("The awsnwer to your equation is " + num1 + num2);
}

Console.ReadLine();
}

}
}
namespace CSLearning
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter your type of equation(+, -, *, /): ");
string typeOfEquation = Console.ReadLine();
if (typeOfEquation.Contains('+'))
{
double num1 = 0;
double num2 = 0;
Console.Write("Enter your first adden: ");
string adden1 = Console.ReadLine();
Console.Write("Enter your second adden: ");
string adden2 = Console.ReadLine();
num1 = Convert.ToDouble(adden1);
num2 = Convert.ToDouble(adden2);
Console.WriteLine("The awsnwer to your equation is " + num1 + num2);
}

Console.ReadLine();
}

}
}
17 replies