# Thread: No idea for a title..really stuck!!

1. ## No idea for a title..really stuck!!

Hi,

Sorry i could not think of a title, but my problem is this. I need to write a program which reads a sum of money in the form of ddd.dd, so 456.89 is ok and then it increases it by 10% and prints on screen. I have this so far but not sure how to multiple a float and double

Code:
```
#include <stdio.h>

int main()
{
float x;
double z= 1.1;

printf( "Please enter the amount of sum: " );
scanf( "%3d %2d", &x);
printf( "Now  we multiply by 10 percent to give: ");
getchar();

}```

2. > scanf( "&#37;3d %2d", &x);
Read your book on scanf, this isn't close to being right.

> I have this so far but not sure how to multiple a float and double
Like the multiply operator perhaps?
Which most people write as *

3. is it better to seperate the before and after decimals so having an extra variable y so that i can have scanf %3d, &x and then scanf %2d, &y ?

4. What about a single &#37;f ?

5. how would i ensure it is exactly in the correct format though and then join them to be multiplied by 10%?

Code:
```#include <stdio.h>

float sum =-1;
const double z =1.1;

int main()
{
printf( "Please enter the amount: " );
scanf( "%f", &sum);
int result = sum+z;
printf( " result: %3d.%2d*z\n", result);

getchar();

}```

6. > how would i ensure it is exactly in the correct format though and then join them to be multiplied by 10&#37;?
Show me how you multiply, then the advanced stuff will follow.

It's good that you're going for maximum validation, but you don't have to get there all in one step.

7. i see i did addition instead...

is there something i need to put after this to do the actual cal? float result = sum * z;

sorry if im sounding thick but i just picked this all up a few days ago and struggling a little

thank you!

8. Not sure ( I am a very beginer also) but think you're looking for something like this
Code:
```#include <stdio.h>

float sum;

float result;

int main()
{
printf( "Please enter the amount: " );
scanf( "&#37;f", &sum);
result= sum*.1;
printf( "result: %.3f\n", result);

return 0;
}```

9. thanks...any help right now is really really appreciated!

10. I read your problem again. I was wrong in my last message, result shown htere is a 10&#37; of a sum, but yo need to see how it increases by 10%

I corrected it, hope it will help

Code:
```#include <stdio.h>

float sum;

float result;

int main()
{
printf( "Please enter the amount: " );
scanf( "%f", &sum);
result=sum+(sum*.1);
printf( "result: %.2f\n", result);

return 0;
}```

11. thank you!

12. i noticed that changing to this ensures that you can only enter 3 sig figs...thanks once again!!

scanf( "&#37;3f %2f", &sum);

13. Originally Posted by nynicue
result=sum+(sum*.1);
If you did your maths correctly, you would know this is the same as:
Code:
`result *= 1.1;`

Popular pages Recent additions