Results 1 to 4 of 4

Thread: resolved - Vb to java any help appreciated ... (1 line)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Location
    UK
    Posts
    127

    Smile resolved - Vb to java any help appreciated ... (1 line)

    can someone help me convert this 1 line of vb code to java ...

    the line below calculates the volume of a bowl in vb (and works)

    Dim dvolume As Double = Math.PI * dRadius * dHeight ^ 2 - (Math.PI * dHeight ^ 3) / 3

    ....

    i have tried to add it to my java android project and am not getting the same result ....

    using

    Double dvolume = Math.pow(Math.PI * dRadius * dHeight, 2) - (Math.pow(Math.PI * dHeight, 3) / 3;

    when i use the values 1.5 for the radius and 1 for the height in my vb app i get the result 3.67 m3

    when i try the same in java with the above example im getting either 12 or -3 which isnt correct can anyone help pls
    Last edited by illskills; May 23rd, 2010 at 01:06 PM.

  2. #2
    Frenzied Member
    Join Date
    Dec 2007
    Posts
    1,072

    Re: Vb to java any help appreciated ... (1 line)

    You are reading your VB code differently than the IDE. The IDE reads it like this:
    Code:
    (Math.PI * dRadius) * (dHeight ^ 2) - (Math.PI * (dHeight ^ 3)) / 3
    Java code:
    Code:
    Double dvolume = Math.PI * dRadius * Math.pow(dHeight, 2) - ((Math.PI * Math.pow(dHeight, 3)) / 3);

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Location
    UK
    Posts
    127

    Re: Vb to java any help appreciated ... (1 line)

    thanks dude im going to try this out now

    ... im new to java (its like learning to walk again lol)

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Location
    UK
    Posts
    127

    Re: Vb to java any help appreciated ... (1 line)

    worked like a dream thanks again dude

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width