using static System.Console;
/// <summary>
/// # # # # # # # # #
/// # Mark Hesser #
/// # Feb 10, 18 #
/// # Property Tax #
/// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
/// # Instructions: #
/// # Write an application that helps landowners determine what their property tax will be for the #
/// current year. Taxes are based on the property’s assessed value and the annual millage rate. The #
/// established millage rate for the current year is $10.03 per $1000 value. Homeowners are given a #
/// $25,000 exemption, which means they may subtract $25,000 from the assessed value prior to #
/// calculating the taxes. Enable users to enter the property address and the prior year’s assessed #
/// value. The township has decided to increase all properties’ assessed value 2.7% for the current #
/// year to add additional monies to the school budget line. Provide meth- ods to compute and return #
/// the new assessed value and the proposed taxes for the current year. Provide another method that #
/// displays the formatted values. #
/// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
/// </summary>
namespace PropertyTax
{
class Tax
{
static void Main(string[] args)
{
#region Declarations
string address = "";
double priorValue = 0, currentValue = 0, currentTax = 0, newTax = 0;
bool quit = false;
#endregion
Title = "Propery Tax";
while (!quit)
{
Clear();
WriteLine(" Please enter the address of the property and the prior year’s assessed value. \n");
address = InputAddress();
priorValue = InputValue();
currentValue = CalcNewValue(priorValue);
currentTax = CalcTax(currentValue);
DisplayResults(address, currentValue, currentTax, newTax);
Quit(ref quit);
}
}
/// <summary>
/// Prompts the User to enter the Properties Address.
/// </summary>
/// <returns></returns>
static string InputAddress()
{
string address = "";
do
{
Write(" Address: ");
address = ReadLine();
if (address == "") //Error if address entered is blank
WriteLine(" No Address Entered… Please Try Again! \n\a");
} while (address == "");
return address;
}
/// <summary>
/// Prompts the User to enter the Property Value.
/// </summary>
/// <returns></returns>
static double InputValue()
{
double value = 0;
do
{
Write(" Property Value: ");
Double.TryParse(ReadLine(), out value);
if (value == 0)
{
WriteLine(" That is not a valid entry… Please Try Again! \n\a");
}
} while (value == 0);
return value;
}
/// <summary>
/// Calculates New Property Value based on the 2.7% increase.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
static double CalcNewValue(double value)
{
const double increasePercent = 1.027;
value = value * increasePercent;
return value;
}
/// <summary>
/// Calculates Property Tax based on current property value.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
static double CalcTax(double value)
{
const double exemption = 25000;
const double taxPercent = .01003;
double tax;
value = value – exemption;
tax = value * taxPercent;
return tax;
}
/// <summary>
/// Displays Address, Current Property Value, and Tax to the user.
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
/// <param name="tax"></param>
/// <param name="newTax"></param>
static void DisplayResults(string address, double value, double tax, double newTax)
{
Clear();
WriteLine(" Propery Address: {0}", address);
WriteLine(" Current Property Value: {0:C}", value);
if (tax == 0)
WriteLine(" No Property Tax is due at this time.", tax);
else if (tax > 0)
WriteLine(" Property Tax Due: {0:C}", tax);
else if (tax < 0)
WriteLine(" Property Tax Refund Owed: {0:C}", tax);
}
/// <summary>
/// Prompts the User to Quit or Continue
/// </summary>
static void Quit(ref bool quit)
{
ConsoleKeyInfo kb;
Write("\n Would you like to Enter another Property? (y/n) "); //Put message to the user here.
kb = ReadKey(); //Listens for Key
if (kb.Key == ConsoleKey.N) //Ends the Program
{
quit = true;
}
else if (kb.Key == ConsoleKey.Y)
{
quit = false;
}
else //Tells the User they are stupid and then Quits the program
{
WriteLine("\n You didn’t hit Y or N. " +
"\n I’m going to assume you said No. " +
"\n Press Any Key Quit…\a");
ReadKey();
quit = true; //Ends Program
}
}
}
}
[/code]