i have some formula.

(find kubik feet) aswer = ((height(inch)/12 * height(inch)/12 * width(feet))/16

i want to solve this formula and asnwer in kiubic feet

i am using double data type and c# language;
ex: height = 48inch ,width =12feet

double height_in_feet = 48/12;
double width_in_feet =12;
double ans=(4*4*12)/16;
Messagebox.Show(ans.toString()); //12.00 kubic feet(its mean 12 feets and 0 inch)
//(maximum inch may be 11 because 12inch = 1feet)
but some time this answer wrong: like height = 44inch ,width =13feet then answer should be 10.11(its mean 10 feet and 11 inchs)

7
Contributors
26
Replies
27
Views
6 Years
Discussion Span
Last Post by ddanbe
Featured Replies

i have some formula.

(find kubik feet) aswer = ((height(inch)/12 * height(inch)/12 * width(feet))/16

i want to solve this formula and asnwer in kiubic feet

i am using double data type and c# language;
ex: height = 48inch ,width =12feet

``````double height_in_feet = 48/12;
double width_in_feet =12;
double ans=(4*4*12)/16;
Messagebox.Show(ans.toString());``````

//12.00 kubic feet(its mean 12 feets and 0 inch)
//(maximum inch may be 11 because 12inch = 1feet)
but some time this answer wrong: like height = 44inch ,width =13feet then answer should be 10.11(its mean 10 feet and 11 inchs)

Edited by elshan0011: code tag issue

Explain a little bit more what you want with an example

The Formula you are using has not problem I couldn't understand yet what is the problem you are facing?... actually you are interpreting it wrong when you say 12.00 cubic feet then it doesn't mean 12 feet and 0 inches and when you say 10.94 then it also doesn't mean 10 feet and 94 inches these are 12 cubic feet and 10.94 cubic feet if you want to change it in inches you have to use the formula of cubic to inch converter

Edited by abelLazm: n/a

Have you checked my answer? this is how you convert a cubic feet in inches

Edited by abelLazm: n/a

why have you put - sign as in 44 -2, 44 -13, 44 -4, 44 -19?

i have some formula.

(find kubik feet) aswer = ((height(inch)/12 * height(inch)/12 * width(feet))/16

i want to solve this formula and asnwer in kiubic feet

i am using double data type and c# language;
ex: height = 48inch ,width =12feet

``````double height_in_feet = 48/12;
double width_in_feet =12;
double ans=(4*4*12)/16;
Messagebox.Show(ans.toString());``````

//12.00 kubic feet(its mean 12 feets and 0 inch)
//(maximum inch may be 11 because 12inch = 1feet)
but some time this answer wrong: like height = 44inch ,width =13feet then answer should be 10.11(its mean 10 feet and 11 inchs)

http://system32.6te.net/formula.jpg

update my image.look it (-) separator

I have checked it but couldn't yet understand

i include some table,they as real values and actual answer for the solution.help it to test the solution and C# cord compilation

I couldn't understand your problem. But i assume that you are not getting the right answer sometimes. Try modifying line 1 like this...

``double height_in_feet= 48.00/12.00``

can you post your code ?

Edited by Arbus: n/a

Yes arbus i also couldn't understand yet what is he asking... in addition to arbus use .00 with every double value
in my opinion answers should be 44, 12 = 10.10
44, 2 = 1.68
44, 4 = 3.4
44, 13 = 10.94
44, 19 = 15.99

Edited by abelLazm: n/a

``````circ           width             aswer
44             4                 3.4 feet
40             7                 4.10 feet
40             16                11.1 feet
40             23                15.11 feet``````

this are the example value and they are 100% correct.i want that answer as in my program.but some answers cannot come in my program.

use my program with my example values abouve

Edited by elshan0011: n/a

I couldn't understand your problem. But i assume that you are not getting the right answer sometimes. Try modifying line 1 like this...

``double height_in_feet= 48.00/12.00``

can you post your code ?

``````private double ChekValue(string width, string hight)
{
double widht = Convert.ToDouble(width);
double height = Convert.ToDouble(hight);
double actual_width_adi_height = widht / 12;
double last_result = result * height;
return last_result;
}``````

Did you do what myself and abelazm said, modifying the double values with .00 ?
Like this...

``````double actual_width_adi_height = widht / 12.00;

Edited by Arbus: n/a

Your code is working fine. Yes arbus have you checked his project in my opinion it is doing what he wants but i dnt know the problem

Edited by abelLazm: n/a

no abellazm, i couldn't check it, i don't have c# compiler and i didn't download some also.

Edited by Arbus: n/a

ok but elshan0011 Let me clear you one thing you have coded perfectly well i have checked and match it with my results your results are right according to the provided formula

Your code is working fine. Yes arbus have you checked his project in my opinion it is doing what he wants but i dnt know the problem

thanks lot for the help.i have some answer table in a book,but i want to do it in problematically.because all ways book reading and get all ways are time wasting work.ok i am try to do it again.....

no abellazm, i couldn't check it, i don't have c# compiler

ok friend!

You aren't using the variables you are defining, but define ans as 12. And you should post to c# forum.

Edited by pyTony: n/a

``double height_in_feet = 48/12;``

This is integer division. What this means is if there is a remainder, it's lost, and then the value is converted to a double. In this case, there isn't a remainder so you have no issue. But what if you put in 45?

``double height_in_feet = 45/12;``

This gives a result of 3 feet, not the 3.75 that you want. To fix this, include the decimal point in all your numbers

``double height_in_feet = 45.0/12.0;``

``double height_in_feet = 48/12;``

This is integer division. What this means is if there is a remainder, it's lost, and then the value is converted to a double. In this case, there isn't a remainder so you have no issue. But what if you put in 45?

``double height_in_feet = 45/12;``

This gives a result of 3 feet, not the 3.75 that you want. To fix this, include the decimal point in all your numbers

``double height_in_feet = 45.0/12.0;``

This is the sample!

``````1foot = 12 inch
double width =12 //foot

double circu = 44/12 ; //to convert foot
double circu_cal =circu*circu*width/16;
double ans_dbl =circu_cal*12; //to accurate and find they are equal
double div_div =ans_dbl/12;// get the perfect value
double rem_div = ans_dbl%12// get remainder

string div_str = Convert.ToDouble( div_div);
string rem_str = Convert.ToDouble(rem_div);
string [] div_arry =div_str.Split('.');
string [] rem_arry =rem_str.Split('.');
int div_int = Convert.ToInt32(div_arry[0]);
int rem_int = Convert.ToInt32(rem_arry[0]);