# Decimal ceil()

• 04-03-2006
peckitt99
Decimal ceil()
i have a problem with rounding off or even getting a decimal plce.

i am trying to work out the vat on 15 which would be 2.625. not only does the program not out put 2.625 just 2 it wont round off to just 2.63.

Here is the coding that i am using

Code:

```                cout << endl;                 cout<<ceil(17.50/100);                 cout << endl;```
can anyone help with my problem?

anything will be a great help thanks
• 04-03-2006
7stud
1)
Quote:

i am trying to work out the vat on 15 which would be 2.625. Here is the coding that i am using
Code:

```                cout << endl;                 cout<<ceil(17.50/100);                 cout << endl;```

Do you expect this:
Code:

`cout<<ceil(17.50/100);`
to display 2.65? In what number system will you get that result?

2)Take a look at this:
Code:

```#include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() {         double vatPercent = 17.5;         double vatDec = 17.5/100;                 double itemPrice = 15.0;         double vat = itemPrice * vatDec;                 cout<<fixed<<setprecision(2)<<vat<<endl;     return 0; }```
• 04-03-2006
peckitt99
Yeah, thats a great help thanks, got that working,

just one more problem tho, where it has the "ItemPrice" and it is set at 15.0, how can i make it so it is a value that the user has inputed?
• 04-03-2006
hk_mp5kpdw
Basic I/O... not that hard to do:

Code:

```double itemPrice; cout << "Enter the price: "; cin >> itemPrice;```
• 04-03-2006
peckitt99
Cheers for that,

I have that working but i have now come (yet again) got another problem, n i have been trying to work it out, it is prob really simple but i now have it to output the sum with the vat added on. i now want to output the sum into a different function eg.

Code:

``` float calculateVAT(float cost)         {                 double vatDec = 17.5/100;                 double itemPrice = cost;                 double vat = itemPrice * vatDec + cost;                 cout<<fixed<<setprecision(2)<<vat<<endl;         } void displayOrder(char initials[], char surname[], char address[],                   char postcode[], int numberOfBottles, float cost,                   float costPlusVAT, float deliveryCharge,float totalCost, int vat)         {                                 cout <<"Cost Including VAT:        " <<POUND<<vat <<endl; }```
anyone know what i can do to solve this new problem??

Thanks
• 04-04-2006
Ideswa
Strange formatting.

Code:

`float calculateVAT(float cost)`
why return a float when you don't return a value?? Use Double for passing values.

The function "calculate" isn't called.