HOW TO MAKE BASIC SALARY IN C# CONSOLE
static void Main(string[] args)
{
// variables
again:
int salary, ca, ma, hr, total_aln, aln_per, pf,it, it_per, total, net;
it = 0;
it_per = 0;
pf = 0;
Boolean check = false;
//input salary
Console.WriteLine();
Console.Write("Enter Basic Salary: ");
salary = Convert.ToInt32(Console.ReadLine());
// CODE TO CHECK NUMERIC SALARY //
///////////////////////////////////////////
// calculation
if (salary > 25000)
{
ca = 40;
ma = 50;
hr = 60;
it = 3;
it_per = 3 * salary / 100;
total_aln = ca + ma + hr;
aln_per = total_aln * salary / 100;
}
else if (salary > 15000)
{
ca = 30;
ma = 40;
hr = 50;
total_aln = ca + ma + hr;
aln_per = total_aln * salary / 100;
}
else
{
check = true;
ca = 500;
ma = 500;
hr = 500;
aln_per = ca + ma + hr;
}
total = salary + aln_per;
net = total - it_per;
///////////////////////////////////////////////////////
Console.WriteLine();
// Output Result
Console.WriteLine("Basic \t CA \t MA \t HR \t Total \t Income Tax \t PF \t Net Salary");
Console.WriteLine();
if (check == false)
{
Console.WriteLine(salary + "\t " + ca + "%\t " + ma + "% \t " + hr + "% \t " + total + " \t " + it + "%\t \t " + pf + " \t " + net);
}
else
{
Console.WriteLine(salary + "\t " + ca + " \t " + ma + " \t " + hr + " \t " + total + " \t " + it + "%\t \t " + pf + " \t " + net);
}
// again calculate
correct:
Console.WriteLine();
Console.WriteLine("Calculate Again ? Y/N");
String again_check = Convert.ToString(Console.ReadLine());
if (again_check == "y" || again_check == "Y")
{
goto again;
}
else if (again_check == "n" || again_check == "N")
{
Environment.Exit(0);
}
else
{
goto correct;
}
Console.Read();
}
{
// variables
again:
int salary, ca, ma, hr, total_aln, aln_per, pf,it, it_per, total, net;
it = 0;
it_per = 0;
pf = 0;
Boolean check = false;
//input salary
Console.WriteLine();
Console.Write("Enter Basic Salary: ");
salary = Convert.ToInt32(Console.ReadLine());
// CODE TO CHECK NUMERIC SALARY //
///////////////////////////////////////////
// calculation
if (salary > 25000)
{
ca = 40;
ma = 50;
hr = 60;
it = 3;
it_per = 3 * salary / 100;
total_aln = ca + ma + hr;
aln_per = total_aln * salary / 100;
}
else if (salary > 15000)
{
ca = 30;
ma = 40;
hr = 50;
total_aln = ca + ma + hr;
aln_per = total_aln * salary / 100;
}
else
{
check = true;
ca = 500;
ma = 500;
hr = 500;
aln_per = ca + ma + hr;
}
total = salary + aln_per;
net = total - it_per;
///////////////////////////////////////////////////////
Console.WriteLine();
// Output Result
Console.WriteLine("Basic \t CA \t MA \t HR \t Total \t Income Tax \t PF \t Net Salary");
Console.WriteLine();
if (check == false)
{
Console.WriteLine(salary + "\t " + ca + "%\t " + ma + "% \t " + hr + "% \t " + total + " \t " + it + "%\t \t " + pf + " \t " + net);
}
else
{
Console.WriteLine(salary + "\t " + ca + " \t " + ma + " \t " + hr + " \t " + total + " \t " + it + "%\t \t " + pf + " \t " + net);
}
// again calculate
correct:
Console.WriteLine();
Console.WriteLine("Calculate Again ? Y/N");
String again_check = Convert.ToString(Console.ReadLine());
if (again_check == "y" || again_check == "Y")
{
goto again;
}
else if (again_check == "n" || again_check == "N")
{
Environment.Exit(0);
}
else
{
goto correct;
}
Console.Read();
}
No comments:
Post a Comment