# Thread: 15 year cost of house- help

1. ## 15 year cost of house- help

I need help with a program. The problem I am having is getting the tax rate to be a percentage.
Code:
```#include <stdio.h>
#define GALPERCUFT 7.4805

/*   This program calculates the 15 year cost of a house */
/*   10/1/07 */

int main(void)
{
int ic, eb, ws, total, tr, eb15, ws15, tr15;

printf("\n	What is the initial cost?	");
scanf("&#37;d", &ic);
printf("\n	How much is the electric bill?	");
scanf("%d", &eb);
printf("\n	How much is the water and sewer bill?	");
scanf("%d", &ws);
printf("\n	What is the tax rate?	");
scanf("%d", &tr);

eb15 = eb * 12 * 15;
ws15 = ws * 12 * 15;
tr15 = tr * ic * 15 * .01;
total = ic + eb15 + ws15 + tr15;

printf("\n    Hurwitz   ");

printf("\n 			Input data");
printf("		15 year data");

printf("\n Initial Cost");
printf("		%d", ic);
printf("			%d", ic);

printf("\n Electric Bill");
printf("		%d", eb);
printf("			%d", eb15);

printf("\n Water and Sewer");
printf("	%d", ws);
printf("			%d", ws15);

printf("\n Tax Rate");
printf("		%d", tr);
printf("%");
printf("			%d", tr15);

printf("\n Total");
printf("						%d", total);
printf("\n\n");
return(0);

}```

2. >The problem I am having is getting the tax rate to be a percentage.
Usually a percentage will be expressed as a floating-point value, from 0.0 to 1.0. Multiplying by 100 gives you the 0 to 100 percentage. Are your values not like that?

3. I don't know.... Can you give me an example of how to do it?

Also, I need to align the output data to the right.

4. >Can you give me an example of how to do it?
Um, (tr * 100)...

>Also, I need to align the output data to the right.
How do you want everything to be formatted? It's hard to tell with your code, so can you post an example?

5. Here's one way to do it. Maybe this will give you some ideas:
Code:
```#include <stdio.h>

int main ( void )
{
printf ( "%25s%21s\n", "Input", "Output" );
printf ( "%-20s%-20d%d\n", "Initial Cost", 235000, 235000 );
printf ( "%-20s%-20d%d\n", "Electric Bill", 185, 33300 );
printf ( "%-20s%-20d%d\n", "Water and Sewer", 54, 9720 );
printf ( "%-20s%-20s%d\n", "Tax Rate", "3.8%", 107160 );

return 0;
}```