First off here is my code:
using System;
using System.Collections.Generic;
using System.Text;
namespace example_1
{
class Program
{
static void Main(string[] args)
{
decimal d = 24;
string input;
Console.WriteLine("Enter A number");
input = Console.ReadLine();
decimal total = Convert.ToDecimal(input), result = (d * total);
Console.WriteLine(result);
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Would you like to repeat?");
repeat = Console.ReadLine();
Console.WriteLine();
Console.WriteLine();
Console.Read();
}
}
}
My Questions:
1. I'd like to add something like an if statement or some kind of loop after the
Console.WriteLine("Would you like to repeat?");
part.
Some thing like this.
repeat = Console.ReadLine();
if (repeat = y)
{
// some code to start the process over
// from the begining.
}
else (repeat = n)
{
// some code to exit application
}
2. How would I implement a check to make sure the user inputs only a number for the first ReadLine part and only 'y' or 'n' for the second?
NOTE:
I've searched all over the web for Tutorials but most are plain code for C# Forms and I don't learn anything from them. And this suits my needs as it is quite simple to code.
Any and all help is appreciated.
Thanks in advance, Poab.