I'm completely new to C & need some help =(

I want to make this clear.... This is a homework project that I'm stuck on so if you feel this is "cheating" then sorry for "offending" you.

How can I change the tax rate in the executable file?

This is my input data:
initial cost: 235000 , 257500, 298900
electric: 185, 135, 150
water & sewer: 54, 46, 53
tax rate %: 3.8, 3.0, 2.6

#include <stdio.h> //printf, scanf definitions
int
main(void)

{

   int initial_cost, electric_bill, water_sewer;
   float tax_rate, total;

   printf("\n Initial cost:    ");
   scanf("%d", &initial_cost);
   printf("\n Electric bill:   ");
   scanf("%d", &electric_bill);
   printf("\n Water & sewer:   ");
   scanf("%d", &water_sewer);
   printf("\n Tax rate:        ");
   scanf("%d", &tax_rate);


  printf("\n                             student name   ");
  printf("\n\n       Input data                                      15 year total\n");

  [B]tax_rate         = ? * initial_cost;[/B]
  total            = initial_cost + electric_bill + water_sewer + tax_rate;


  printf ("   \nInitial cost :  = %10.0d", initial_cost );
  printf ("   \nElectric bill: =  %10.0d", electric_bill);
  printf ("   \nWater & Sewer: =  %10.0d", water_sewer  );
  printf ("   \nTax rate:      =  %13.2f", tax_rate     );
  printf ("   \nTotal:         =  %10.0f", total        );
  return(0)
}

to make this clear .. the assignment x.x

Assignment -

When shopping for a new house several factors should be considered. In this problem the initial cose of the house, the monthly electric bill, the mothly water & sewer bill, and the annual tax rate are available. Write a program that will allow the user to impt the initial cost of the house, momthly electric bill, monthly water & sewer bill, and the tax rate. The program should print out the input  data and calculate and print the total cost of the house for 15 years. 

To calculate the 15 year total cost  add the initial cost of the house to the electric bill for 15 years and the water  & sewer bill for 15 years, to this add the taxes for 15 years. To calculate the taxes for on year multiply the tax rate by the initial cost of the house.

I don't want someone to do the project for me.. just simply point me in the correct direction (yell & scream if you must :P) :D.. thanks ~

Recommended Answers

All 6 Replies

Your tax rate for each year will be something like:

YearlyTaxRate = intial_cost * tax_rate;

Your current code states

tax_rate         = ? * initial_cost;
  total            = initial_cost + electric_bill + water_sewer + tax_rate;

tax_rate is the variable where you are storing the user input. So define another variable say yearlyTaxRate as shown above. Once you have the yearly tax rate you can compute it for the next 15 years.

Now your total will be

initial_cost + taxes for 15 years + electric for 15 years + water_sewer for 15 years.

You also need to compute the electric and water sewer bills for the next 15 years given the monthly value.

Alright, thanks for you help however I'm still a bit stuck...

Image of current project -

poke me ^.^


Digits aren't lined up & tax rate is incorrect...

If I use 3.8% I get 0.00
If I use .038 I get na & an -digit

sorry for double post~

Update (couldn't edit o.o)

Image of current project --> Poke me ^.^


only problem now is tax rate.. Should I be looking for some type of formula? x.x

thanks~

You try to get tax_rate with wrong format specifier (%d used only for int values but your tax_rate is float).
Must be:

scanf("%f", &tax_rate);

Better use double type for all your numbers. Don't forget that input format specifier for double is %lf, not %f.

o.o

when the program is executed how do I tell the program to input the tax rate

I know the formula for tax rate = annual tax / assessed value * tax rate

I just don't know how to define that equation in C.

I want the program to ask me to input the tax rate without having to go back into the source code & changing it.

Updated version of the code

thanks for posting

A couple of things.

One, as per your problem definition, the user inputs the monthly charges for electric and water sewer.

So your total for 15 years for these two utilities would be monthly_charges * 12 * 15

You are already asking the user to input the tax_rate .. based on which you are computing the total tax for each year. So I am not sure I understand that question correctly ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.