Check value range with if else statement - CSharp Language Basics

CSharp examples for Language Basics:if

Description

Check value range with if else statement

Demo Code

using System;//  ww  w  .  j ava 2 s.  co m
class CompactBalanceAssessment
{
   public static void Main()
   {
      decimal balance;
      Console.Write("Enter balance: ");
      balance = Convert.ToDecimal(Console.ReadLine());
      if(balance >= 5000 && balance <= 20000)
         Console.WriteLine("Balance is in category A");
      else if(balance >= 60000 && balance <= 75000)
         Console.WriteLine("Balance is in category B");
      else
         Console.WriteLine("Balance is in category C");
   }
}

Result


Related Tutorials