People who earn less than R6 000.00 or who are older than 70 years do not pay tax. Write a program that reads in a person’s salary and age. If the person should pay tax, your program should request the tax percentage. The program must finally display an appropriate message.
using System;
namespace Tax
{
class Program
{
public static void Main(string[] args)
{
double salary, tax, taxperc;
int years;
Console.Write("Enter salary: ");
salary = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter age: ");
years = Convert.ToInt32(Console.ReadLine());
tax = 0;
if ((salary >= 6000) && (years < 70))
{
Console.Write("Enter tax percentage: ");
taxperc = Convert.ToInt32(Console.ReadLine());
tax = (salary * taxperc)/100;
Console.WriteLine();
Console.WriteLine("Tax: R{0:f2}", tax);
}
else
{
Console.WriteLine();
Console.WriteLine("Not pay tax");
}
Console.WriteLine();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
Comments
Leave a comment