+ 2
How do i make this code say error when wrong input is done
5 Antworten
+ 2
Inclose the code in an if else statement that if ( x is right) then .... else {error}
+ 2
i dont understand
+ 2
ok
+ 1
I have not worked with CS but is there something like a try: except: to try ... if error ...
0
You can handle a wrong input with try catch:
try{
BankAccount b = new BankAccount();
b.Deposit( Convert.ToInt32(Console.ReadLine()));
b.Withdraw( Convert.ToInt32(Console.ReadLine()));
Console.WriteLine("Your balance :"+(b.GetBalance()));
}catch(Exception e)
{
Console.WriteLine("Wrong Input! ");
}