class TaxCalculator
attr_accessor :legal_name, :total_income, :health_insurance,
:pension, :unemployment, :flat_tax_rate
@@flat_tax_rate=0.10 #The flat income tax rate is the same across
all individuals.
def
initialize(legal_name,total_income,health_insurance,pension,unemployment)
#This method creates new instances.
@legal_name=legal_name
@total_income=Float(total_income)
@health_insurance=Float(health_insurance)
@pension=Float(pension)
@unemployment=Float(unemployment)
end
def
taxcalculator(flat_tax_rate,health_insurance,pension,unemployment,total_income)#This
method computes the final tax bill.
Float(flat_tax_rate*[(health_insurance+pension+unemployment)*total_income])
end
def to_s #This provides a brief summary of the taxpayer’s individual
profile.
“Legal Name: #{@legal_name}, Total income:#{@total_income},
health insurance premium rate:#{@health_insurance}, pension
rate:#{@pension}, unemployment insurance rate:#{@unemployment}”
end
end
puts “Libertyland Income Tax Calculator Program”
puts “Legal Name:”
legal_name=gets.to_s
print “Enter total income:$”
total_income=gets.to_f
if total_income<=15000
puts “Your current annual income exempts you from paying income
taxes.”
else
print “Enter total health insurance rate:”
health_insurance=gets.to_f
print "Enter total pension rate:"
pension=gets.to_f
print "Enter total unemployment rate:"
unemployment=gets.to_f
tax_payer_profile=TaxCalculator.new(legal_name,total_income,health_insurance,pension,unemployment)
puts tax_payer_profile
puts "Your tax bill is:$#{tax_payer_profile.taxcalculator}"
end
I wrote the code above and I keep getting an error that says I have the
wrong number of arguments (0 for 5) for the class method
‘taxcalculator’.
How do I write the method properly?