Saving Calculator in C#

Saving Calculator in C#

Saving Calculator is a simple console application in Visual C#. In this application, We assume that a pensioner has 3 sources of income. They are pension, rent and gift from his children. Here we want to receive these varying amounts from the user. Then, we have to output the following

  • Total Income:- (Sum of incomes through all three sources)
  • Saving Amount:- (Remaining after spending)
  • Tax Status:- (Eligible to pay tax if the total income is greater than 50000)
  • Tax Amount:- (8% of total income if he is eligible to pay tax)

Implementation of Salary Calculator in C#

static void Main(string[] args)
{
     //Declaration of Variables
     double pension, rent, gift, total, spent, saving, tax = 0;
     string status = "Non Tax Payee";

     //Displaying an Instruction
     Console.WriteLine("Enter your pension amount :");
     //Getting the user input and converting to Integer
     pension = Convert.ToInt32(Console.ReadLine());

     Console.WriteLine("Enter your rent amount :");
     rent = Convert.ToInt32(Console.ReadLine());

     Console.WriteLine("Enter your gift amount :");
     gift = Convert.ToInt32(Console.ReadLine());

     Console.WriteLine("Enter the amount spent :");
     spent = Convert.ToInt32(Console.ReadLine());

     //Getting the total
     total = pension + rent + gift;

     //Getting the saving
     saving = total - spent;

     //Checking whether entitled to pay tax or not 
     if (total >= 50000)
     {
          status = "Tax Payee";
          tax = 0.08 * total;
     }

     //Outputs
     Console.WriteLine("ToTal Income \t\t: Rs." + total);
     Console.WriteLine("Saving Amount \t\t: Rs." + saving);
     Console.WriteLine("Tax Status \t\t: " + status);
     Console.WriteLine("Tax Amount \t\t: Rs." + tax);

     //ReadKey() will wait until a key is pressed.
     //So that we can see the output
     Console.ReadKey();
}

In the above example, we illustrate how to get user input from command line and processing those information.

Below you can download the Saving Calculator in C# Command Line Application.

LEAVE A REPLY

Please enter your comment!
Please enter your name here