I'm pretty new to c# and am confused on how to set the data members and then calculate the tax with a different method. Here is what this part of the program should do:
"If the user selects default the default values you will instantiate a rates object using the default constructor and set the Taxpayer class data member for tax equal to the value returned from calling the rates object CalculateTax method."
-I have a switch statement calling for the default constructor if they choose 'D', I'm not sure how to set the taxpayer class data to default, i'm not sure if the CalculateTax method is correct either.
and then do the same type of thing if they choose 'O'
Here is what I have so far:
using System;
interface Icomparable
{
int CompareTo(Object o);
}
class rates
{
public double Limit{get;}
public double LowRate{get;}
public double HighRate{get;}
private rates()
{
Limit = 30000;
LowRate = 0.15;
HighRate = 0.28;
}
public rates(double Limit; double LowRate; double HighRate;)
{
Console.Write("Enter dollar limit: ");
Limit = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the low rate: ");
LowRate = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the high rate: ");
HighRate = Convert.ToDouble(Console.ReadLine());
}
public CalculateTax()
{
if(Income < Limit)
{TaxOwed = (Income * LowRate)}
else
{TaxOwed = (Income * HighRate)}
}
}
public class taxpayer : IComparable
{
public string SSN{get; set;}
public double Income{get; set;}
public double TaxOwed{get;}
int IComparable.CompareTo(Object o)
{
int returnVal;
taxpayer temp = (taxpayer)o;
if(this.TaxOwed > temp.TaxOwed)
returnVal = 1;
else
if(this.TaxOwed < temp.TaxOwed)
returnVal = -1;
else
returnVal = 0;
return returnVal;
}
public getRates()
{
double Limit;
double LowRate;
double HighRate;
Console.WriteLine("Do you want default values(enter D) or enter your own (enter O)?");
entry = Convert.ToChar(Console.ReadLine());
switch (entry) //set switch
{
case'D':
rates();
break;
case'O':
rates(double Limit; double LowRate; double HighRate;)
break;
default:
Console.WriteLine("Invalid input");
goto getRates();
}
}
}
Any help with this would be very much appreciated.
I don't see why you would keep re creating an object that you have all the values for.
Here is an alternate pattern, static presets + factory
class Rates
{
public double Limit{get;}
public double LowRate{get;}
public double HighRate{get;}
static readonly Rates default = new Rates(30000,0.15,0.28);
static readonly Rates govna = new Rates(300000,0.1,0.2);
static readonly Rates priest = new Rates(300,0.05,0.07);
public static Rates createRates()
{
double Limit; double LowRate; double HighRate;
Console.Write("Enter dollar limit: ");
Limit = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the low rate: ");
LowRate = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the high rate: ");
HighRate = Convert.ToDouble(Console.ReadLine());
return new Rates( Limit, LowRate, HighRate );
}
private Rates(double limit; double lowRate; double highRate;)
{
Limit = limit;
LowRate = lowRate;
HighRate = highRate;
}
public double CalculateTax( double Income)
{
if(Income < Limit)
{return (Income * LowRate)}
else
{return (Income * HighRate)}
}
}
Oh and whats with goto?
while( null == ratesResult ){
Console.WriteLine("Do you want default values(enter D) or enter your own (enter O)?");
entry = Convert.ToChar(Console.ReadLine());
switch (entry) //set switch
{
case'D':
ratesResult = Rates.default;
break;
case'O':
ratesResult = Rates.createRates();
break;
default:
Console.WriteLine("Invalid input");
}
}
You have many problems with your code, buddy. Here is some advice that might guide you in the right direction.
In the following properties, you should also have a set; accessor to be able to store those values.
public double Limit{get;}
public double LowRate{get;}
public double HighRate{get;}
In the following function, do you want to prompt the user to enter values? If so, change the first line from
public rates(double Limit; double LowRate; double HighRate;)
to
public rates(bool dummy)
Now your code will look like
public rates(bool dummy) //Note that dummy is not used in this function. It just distinguishes rates() from rates(bool)
{
Console.Write("Enter dollar limit: ");
Limit = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the low rate: ");
LowRate = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the high rate: ");
HighRate = Convert.ToDouble(Console.ReadLine());
}
the dummy is just to allow the the code to distinguish your two different functions.
In your switch statement, just call the rates(bool dummy) function instead of the other one. For the dummy, assign it either true or false, who cares.... It'd look like the following.
switch (entry) //set switch
{
case'D':
rates();
break;
case'O':
rates(true)
break;
default:
Console.WriteLine("Invalid input");
goto getRates();
}
There's more problems with your code, but you have to revise it before we can help you further. You should actually try to use it in VS, since the editor can help you fix problems by giving you specific errors.
Related
am trying to make a mastermind game using an array of ints where I having the user guess a number sequence between 4-10 instead of colours. My GetAValidNumber is suppose to displays a prompt to the user and
get a number from the user in the minimum/maximum range as specified in
the parameters. If the number entered is outside the minimum/maximum
range, then an error message is suppose to be displayed and
the user is re-prompted for the number but for some reason it isn't validating properly.
Any Guidance would be appreciated
public static int GetAValidNumber(string inputMessage)
{
// declare variables
int validInteger;
bool inputIsValid = false;
int lowValue = 1;
int highValue = 10;
while (!int.TryParse(Console.ReadLine(), out validInteger))
{
Console.WriteLine("Invalid entery - try again.");
Console.Write(inputMessage, lowValue, highValue);
do
{
while (!int.TryParse(Console.ReadLine(), out validInteger))
{
Console.WriteLine("Invalid entery - try again.");
Console.Write(inputMessage);
}
if (validInteger < lowValue || validInteger > highValue)
{
Console.WriteLine("Your number is out of Range: ");
}
else
{
inputIsValid = true;
}
} while (validInteger < lowValue || validInteger > highValue);
}
return validInteger;
}
// This method directs the play of the game
public static void PlayGame()
{
int userNumbers;
int userGuess;
int difficulty;
int randomNumbers;
Console.WriteLine("How Many Numbers Would You Like To Use When Playing(4-10): ");
userNumbers = GetAValidNumber(Console.ReadLine());
Console.WriteLine("Choose a difficulty level (1 -3");
difficulty = GetAValidNumber(Console.ReadLine());
Console.WriteLine("A 5-digit number has been chosen. Each possible digit may be the number 1, 2, 3, or 4");
Console.ReadLine();
Console.WriteLine("Enter Your Guess {0} guesses remaning", GetGameDifficulty(difficulty, randomNumbers = GetRandomNumberCount(difficulty)));
userGuess = GetAValidNumber(Console.ReadLine());
Console.WriteLine("Your Guess was {0}, Your Results are {1}", userGuess, CountHits(userGuess, randomNumbers));
Console.ReadLine();
}
Here's a simplified version of your code:
public static int GetAValidNumber(string inputMessage)
{
int validInteger = 0;
//Range between 4 to 10
int lowValue = 4;
int highValue = 10;
int.TryParse(inputMessage, out validInteger);
while (validInteger < lowValue || validInteger > highValue)
{
Console.WriteLine("Invalid entery - try again.");
inputMessage = Console.ReadLine();
int.TryParse(inputMessage, out validInteger);
}
return validInteger;
}
The issue here is you are having multiple while loops that is not validating your inputs correctly.
Take note that on your other validating number inputs you need different ranges so I would suggest setting the lowValue and highValue as extra parameters on your function:
public static int GetAValidNumber(string inputMessage, int lowValue, int highValue)
So this is my budget calculator.
It calculates how much i can earn with deposit(% per year), i can add money(earnings) and can decrease money(loosing).
In my code you have to manually tell the size of starting money.
What i need is for example in the beginning i tell my program that starting capital is 500euro. When i use deposit, it become for example 570,50. When i use earnings, i need it to start from 570,50, but in my program it will always ask again, what is your starting capital. I need to do it automatically somehow. Sorry for my bad english and here is the whole code :)
class Program
{
static void Main(string[] args)
{
int menu;
do
{
Console.WriteLine("1 - '%'");
Console.WriteLine("2 - '+'");
Console.WriteLine("3 - '-'");
Console.WriteLine("0 - iziet");
Console.Write("Menu: ");
menu = Convert.ToInt32(Console.ReadLine());
if (menu > 0 && menu < 4)
{
switch (menu)
{
case 1:
{
Console.Write("Noguldamā naudas summu: ");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("Procentu likme (0 - 100): ");
int b = Convert.ToInt32(Console.ReadLine());
Console.Write("Laiks (gadi): ");
int c = Convert.ToInt32(Console.ReadLine());
double d = Procenti(a, b, c);
Console.WriteLine("\nNaudas summa pēc {0} gadiem būs {1}\n", c, d);
}
break;
case 2:
{
Console.Write("Sakuma nauda: ");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("Cik nopelnijat: ");
int b = Convert.ToInt32(Console.ReadLine());
double d = Pluss(a, b);
Console.WriteLine("Tagadejais budzhets ir: {0} euro", d);
}
break;
case 3:
{
Console.Write("Sakuma nauda: ");
double a = Convert.ToDouble(Console.ReadLine());
Console.Write("Cik izterejat: ");
double b = Convert.ToDouble(Console.ReadLine());
double d = Minuss(a, b);
Console.WriteLine("Tagadejais budzhets ir: {0} euro", d);
}
break;
}
}
else
{
Console.WriteLine();
Console.WriteLine("Ludzu ievadiet ciparus 0,1,2,3 - parejie cipari ir arpus robezham!");
Console.WriteLine();
}
} while (menu != 0);
}
//FUNKCIJASSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
static double Procenti(double a, double b, int c)
{
for (int i = 0; i < c; i++)
{
a = (a * (b / 100) + a);
}
return a;
}
static double Pluss(double a, double b)
{
return a + b;
}
static double Minuss(double a, double b)
{
return a - b;
}
}
you need to store the value inside a variable.
and before to start the transactions you ask the user for the value :
int menu;
float stored_money;
Console.Write("Enter the Initial Value: ");
stored_money = Convert.ToInt32(Console.ReadLine());
do
{
and in the functions use this variable
static double Pluss(double b)
{
stored_money = stored_money + b;
return stored_money;
}
static double Minuss(double b)
{
stored_money = stored_money - b;
return stored_money;
}
Well, basically it looks like you need to save your balance amount somewhere in your code, because right now you're entering it from console in each menu point.
Something like (note I've omitted most of code):
int menu;
decimal amount;
do
{
.... //your code
case 1:
{
Console.Write("Noguldamā naudas summu: ");
amount = Convert.ToDecimal(Console.ReadLine());
.... //your code
decimal d = Procenti(a, b, c);
amount += d;
}
case 2:
{
Console.Write("Cik nopelnijat: ");
decimal b = Convert.ToInt32(Console.ReadLine());
amount = Pluss(amount, b);
Console.WriteLine("Tagadejais budzhets ir: {0} euro", amount);
}
.... //your code
} while (menu != 0);
And later in all cases you should not enter amount, but use that saved value and modify it according to menu point task.
Or maybe you even should introduce new menu point to set initial amount and don't enter it in point 1 (if point 1 can be called multiple times) - it depends on your calculator logic and it's up to you.
Note - it's better to use decimal rather that int and double for financial calculations as it is designed to store full possible precision.
The application shall perform the selected menu math operation on the two entered numbers and display the answer.You must use methods for each math operation and a decision must be used to pick which method should be executed.
The application shall display an error message when a correct menu number is not entered. This is a decision where 1-5 are valid selections and everything else is “Invalid”.
The application shall not allow division by zero. Do not perform the divide operation if the second number variable is zero, but instead display an error message.
I have written the code but the program is showing the following error:
1. No overload for method AddNumber takes 0 arguments. this error is showing for all math operation methods inside the switch statements.
2. For DivideNumber method - not all code paths return a value
class Program
{
static void Main(string[] args)
{
double n1 = Convert.ToDouble(Console.ReadLine());
//string n2 = "";
double n2 = Convert.ToDouble(Console.ReadLine());
Console.Clear();
Console.WriteLine("Simple Calculator");
Console.WriteLine("\t 1) ADD");
Console.WriteLine("\t 2) SUBTRACT");
Console.WriteLine("\t 3) MULTIPLY");
Console.WriteLine("\t 4) DIVIDE");
Console.WriteLine("\t 5) QUIT");
Console.Write("Enter Selection: ");
int menuSelection =0;
// double total;
// menuSelection = Console.ReadLine();
switch (menuSelection)
{
case 1:
// total = Convert.ToInt32(AddNumbers("Results:"));
Console.WriteLine(AddNumbers(n1,n2));
break;
case 2:
Console.WriteLine(SubtractNumber(n1,n2));
break;
case 3:
Console.WriteLine(MultiplyNumber(n1,n2));
break;
case 4:
Console.WriteLine(DivideNumber(n1,n2));
break;
case 5:
break;
default:
Console.WriteLine("Invalid Selection !");
Console.ReadLine();
return;
}
//Ask user to enter two numbers
Console.WriteLine();
Console.Write("Enter Number 1:", n1);
// number1 = Console.ReadLine();
Console.Write("Enter Number 2:", n2);
// number2 = Console.ReadLine();
}
public static double AddNumbers(double number1, double number2)
{
return number1 + number2;
}
public static double SubtractNumber(double number1, double number2)
{
return number1 - number2;
}
public static double MultiplyNumber(double number1, double number2)
{
return number1 * number2;
}
public static double DivideNumber(double number1, double number2)
{
if (number1 == 0 && number2 == 0)
{
Console.WriteLine("Cannot Divide by Zero. Try Again");
return 0;
}
else
{
return number1 / number2;
}
}
1st mistake You are taking input after calling switch cases
2nd mistake your function have two parameters so pass them.
like DivideNumber(number1,number2) in your switch case
hope you understand
one thing i notice is you are taking input in string and your function takes double parameters so you need to convert string to double.
Give you idea use double to take input like double n1 = Convert.ToDouble(console.readline()); as input from console is string.
you are calling your function return AddNumbers();
but have declared it as public static double AddNumbers(double number1, double number2)
AddNumbers expected 2 numbers, you have passed 0.
You don't return anything from DivideNumbers, though you have declared it to return a double. public static double DivideNumber
The program makes no sense as it is. You are trying to do the operation before they've even given you the numbers. You should try to Rubber Duck this one yourself
This should do what your trying to accomplish.
I have this question that I have to do for an assignment for school. I am having troubles making it work with decimals. If someone could help me get the program to accept decimals. It will output a decimal but it won't let me input one.
using System;
public class Bank_Account
{
public static void Main()
{
char input, C, D, P, Q;
double balance;
Console.WriteLine("Please enter C for Cheque, D for Deposit, P for Print or Q to quit");
input = Convert.ToChar(Console.ReadLine());
do
{
switch (input)
{
case 'D':
Deposit(ref balance);
break;
case 'P':
Print(balance);
break;
case 'C':
Cheque(ref balance);
break;
default:
Console.WriteLine("{0} is not a valid choice", input);
break;
}
} while (input != 'Q');
}
public static void Deposit(ref double balance)
{
double deposit;
Console.WriteLine("Enter the amount you want to deposit: ");
deposit = Convert.ToInt32(Console.ReadLine());
if (deposit > 1000)
{
deposit = deposit*1.02;
}
else
{
deposit = deposit;
}
balance = +deposit;
}
public static void Cheque(ref double balance)
{
var tempBalance = balance;
double deduction;
const double fee = 1;
do
{
Console.WriteLine("Enter the amount of the cheque: ");
deduction = Convert.ToInt32(Console.ReadLine());
} while (deduction < 0);
tempBalance = balance - deduction - fee;
if (tempBalance < 0)
{
Console.Write("Not enough money in the account");
}
else
{
balance = tempBalance;
}
}
public static void Print(double balance)
{
Console.WriteLine("Your current balance is {0.00}", balance);
}
}
Change this:
deposit = Convert.ToInt32(Console.ReadLine());
to:
deposit = Convert.ToDouble(Console.ReadLine());
since you're not reading an int, but a double. Using TryParse like suggested in another answer would be even better. Also, maybe you should be using decimal and not double if you need exactness, but double if accuracy is less of a concern.
You are converting to Int, change like this,
do
{
Console.WriteLine("Enter the amount of the cheque: ");
deduction = Convert.ToDouble(Console.ReadLine());
}
Try This:
double deposit;
double.TryParse(Console.ReadLine(),out deposit);
deposit = Double.Parse(Console.ReadLine());
I am getting the following output when this program is run:
Please enter the Social Security Number for taxpayer 0: 111111111
Please enter the gross income for taxpayer 0: 20000
Please enter the Social Security Number for taxpayer 1: 555555555
Please enter the gross income for taxpayer 1: 50000
Please enter the Social Security Number for taxpayer 2: 333333333
Please enter the gross income for taxpayer 2: 5464166
Please enter the Social Security Number for taxpayer 3: 222222222
Please enter the gross income for taxpayer 3: 645641
Please enter the Social Security Number for taxpayer 4: 444444444
Please enter the gross income for taxpayer 4: 29000
Taxpayer # 1 SSN: 111111111, Income is $20,000.00, Tax is $0.00
Taxpayer # 2 SSN: 555555555, Income is $50,000.00, Tax is $0.00
Taxpayer # 3 SSN: 333333333, Income is $5,464,166.00, Tax is $0.00
Taxpayer # 4 SSN: 222222222, Income is $645,641.00, Tax is $0.00
Taxpayer # 5 SSN: 444444444, Income is $29,000.00, Tax is $0.00
Unhandled Exception: System.InvalidOperationException: Failed to compare two elements in the array. ---> System.ArgumentException: At least one object must implement IComparable.
at System.Collections.Comparer.Compare(Object a, Object b)
at System.Collections.Generic.ObjectComparer`1.Compare(T x, T y)
at System.Collections.Generic.ArraySortHelper`1.SwapIfGreaterWithItems(T[] keys, IComparer`1 comparer, Int32 a, Int32 b)
at System.Collections.Generic.ArraySortHelper`1.QuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer)
at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer)
--- End of inner exception stack trace ---
at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer)
at System.Array.Sort[T](T[] array, Int32 index, Int32 length, IComparer`1 comparer)
at System.Array.Sort[T](T[] array)
at Assignment5.Taxpayer.Main(String[] args) in Program.cs:line 150
Notice the 0s at the end of the line that should be the tax amount???
Here is the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace taxes
{
class Rates
{
// Create a class named rates that has the following data members:
private int incLimit;
private double lowTaxRate;
private double highTaxRate;
// use read-only accessor
public int IncomeLimit
{ get { return incLimit; } }
public double LowTaxRate
{ get { return lowTaxRate; } }
public double HighTaxRate
{ get { return highTaxRate; } }
//A class constructor that assigns default values
public Rates()
{
int limit = 30000;
double lowRate = .15;
double highRate = .28;
incLimit = limit;
lowTaxRate = lowRate;
highTaxRate = highRate;
}
//A class constructor that takes three parameters to assign input values for limit, low rate and high rate.
public Rates(int limit, double lowRate, double highRate)
{
}
// A CalculateTax method that takes an income parameter and computes the tax as follows:
public int CalculateTax(int income)
{
int limit = 0;
double lowRate = 0;
double highRate = 0;
int taxOwed = 0;
// If income is less than the limit then return the tax as income times low rate.
if (income < limit)
taxOwed = Convert.ToInt32(income * lowRate);
// If income is greater than or equal to the limit then return the tax as income times high rate.
if (income >= limit)
taxOwed = Convert.ToInt32(income * highRate);
return taxOwed;
}
} //end class Rates
// Create a class named Taxpayer that has the following data members:
public class Taxpayer
{
//Use get and set accessors.
string SSN
{ get; set; }
int grossIncome
{ get; set; }
// Use read-only accessor.
public int taxOwed
{
get { return taxOwed; }
}
// The Taxpayer class should be set up so that its objects are comparable to each other based on tax owed.
class taxpayer : IComparable
{
public int taxOwed { get; set; }
public int income { get; set; }
int IComparable.CompareTo(Object o)
{
int returnVal;
taxpayer temp = (taxpayer)o;
if (this.taxOwed > temp.taxOwed)
returnVal = 1;
else
if (this.taxOwed < temp.taxOwed)
returnVal = -1;
else
returnVal = 0;
return returnVal;
} // End IComparable.CompareTo
} //end taxpayer IComparable class
// **The tax should be calculated whenever the income is set.
// The Taxpayer class should have a getRates class method that has the following.
public static void GetRates()
{
// Local method data members for income limit, low rate and high rate.
int incLimit = 0;
double lowRate;
double highRate;
string userInput;
// Prompt the user to enter a selection for either default settings or user input of settings.
Console.Write("Would you like the default values (D) or would you like to enter the values (E)?: ");
/* If the user selects default the default values you will instantiate a rates object using the default constructor
* and set the Taxpayer class data member for tax equal to the value returned from calling the rates object CalculateTax method.*/
userInput = Convert.ToString(Console.ReadLine());
if (userInput == "D" || userInput == "d")
{
Rates rates = new Rates();
rates.CalculateTax(incLimit);
} // end if
/* If the user selects to enter the rates data then prompt the user to enter values for income limit, low rate and high rate,
* instantiate a rates object using the three-argument constructor passing those three entries as the constructor arguments and
* set the Taxpayer class data member for tax equal to the valuereturned from calling the rates object CalculateTax method. */
if (userInput == "E" || userInput == "e")
{
Console.Write("Please enter the income limit: ");
incLimit = Convert.ToInt32(Console.ReadLine());
Console.Write("Please enter the low rate: ");
lowRate = Convert.ToDouble(Console.ReadLine());
Console.Write("Please enter the high rate: ");
highRate = Convert.ToDouble(Console.ReadLine());
Rates rates = new Rates(incLimit, lowRate, highRate);
rates.CalculateTax(incLimit);
}
}
static void Main(string[] args)
{
Taxpayer[] taxArray = new Taxpayer[5];
Rates taxRates = new Rates();
// Implement a for-loop that will prompt the user to enter the Social Security Number and gross income.
for (int x = 0; x < taxArray.Length; ++x)
{
taxArray[x] = new Taxpayer();
Console.Write("Please enter the Social Security Number for taxpayer {0}: ", x + 1);
taxArray[x].SSN = Console.ReadLine();
Console.Write("Please enter the gross income for taxpayer {0}: ", x + 1);
taxArray[x].grossIncome = Convert.ToInt32(Console.ReadLine());
}
Taxpayer.GetRates();
// Implement a for-loop that will display each object as formatted taxpayer SSN, income and calculated tax.
for (int i = 0; i < taxArray.Length; ++i)
{
Console.WriteLine("Taxpayer # {0} SSN: {1}, Income is {2:c}, Tax is {3:c}", i + 1, taxArray[i].SSN, taxArray[i].grossIncome, taxRates.CalculateTax(taxArray[i].grossIncome));
} // end for
// Implement a for-loop that will sort the five objects in order by the amount of tax owed
Array.Sort(taxArray);
Console.WriteLine("Sorted by tax owed");
for (int i = 0; i < taxArray.Length; ++i)
{
Console.WriteLine("Taxpayer # {0} SSN: {1}, Income is {2:c}, Tax is {3:c}", i + 1, taxArray[i].SSN, taxArray[i].grossIncome, taxRates.CalculateTax(taxArray[i].grossIncome));
}
} //end main
} // end Taxpayer class
} //end
Any clues as to why the dollar amount is coming up as 0 and why the sort is not working?
Your second Rates constructor does nothing.
Taxpayer.taxOwed is infinitely recursive.
I don't think it's necessary to call Convert.ToString on a string:
userInput = Convert.ToString(Console.ReadLine());
You never use the result of calling Rates.CalculateTax.
GetRates doesn't do anything with the Rates objects that it instantiates; calling it appears to do nothing.
The nested class taxpayer doesn't seem to be used for anything. Are you trying to make Taxpayer IComparable? You would implement IComparable right in the Taxpayer class. You shouldn't define a separate class. You probably also want to implement IComparable<Taxpayer> instead.
You are using your program class for your data. You should probably split Taxpayer away from your program class. It should be a separate class like Rates is.
Rates rates = new Rates(incLimit, lowRate, highRate);
rates.CalculateTax(incLimit);
you are passing a value to constructor where there is no implementation
//A class constructor that takes three parameters to assign input values for limit, low rate and high rate.
public Rates(int limit, double lowRate, double highRate)
{
}
assign the values to the methods inside this constructor and try running the program,
Try to debug and tell us where you are facing the problem.