Click here to Skip to main content
15,173,311 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
String name;
Console.WriteLine("Enter the Customer name");
name = Console.ReadLine();

int initialDep;
Console.WriteLine("Enter the " + name + "initial deposit for Saving Account");
initialDep = Convert.ToInt32(Console.ReadLine());

int monthly;
Console.WriteLine("Enter the " + name + "monthly deposit for Saving Account");
monthly = Convert.ToInt32(Console.ReadLine());

What I have tried:

its C# code, I am trying to go with switch statement but its bit confusing
Posted
Updated 23-Feb-18 7:13am
Comments
Tim Carmichael 23-Feb-18 11:46am
   
What do you mean by 'user enter the wrong one'?
If you mean: until they enter someone that is not valid, what makes it not valid?

1 solution

C#
int initialDep;
Console.WriteLine("Enter the {0} initial deposit for Saving Account", name);
while (!int.TryParse(Console.ReadLine(), out initialDep))
{
    Console.WriteLine("Please enter a valid number!");
}
Repeat for the other input.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900