Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
| Search | Today's Posts | Mark Forums Read
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 23rd, 2004, 12:43 PM
Registered User
 
Join Date: May 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default help on vol of sphere

Hi everyone,

im new on java..
currently reading ch2
there's this execrise at the end of ch2 which i dun quite get it
pg75 Q4

here's goes:
nSunVol = (long) (Math.PI * Math.pow ((nSunDia /2), 3) * 4/3);
nSunVol = (long) (4/3 * Math.PI * Math.pow ((nSunDia /2), 3));

it seen to me tat if i code it as L1 the ans is correct.
but when i coded it in L2 by switching the 4/3 to the front. It doesnt work.
Can anyone explain to me y?

thx

 
Old May 26th, 2004, 04:57 AM
Registered User
 
Join Date: May 2004
Location: Delhi, , India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to omindra
Default

one can be u specified your variable as class variable
nothing wrong in this line
following program compile well

class SunVolume
{

  public static void main(String args[])
 {
       long nSunVol,nSunDia=17;
      nSunVol = (long) (Math.PI * Math.pow ((nSunDia /2), 3) * 4/3);
      System.out.println(nSunVol);
}
}






Similar Threads
Thread Thread Starter Forum Replies Last Post
Sphere - class or object on pg 189 Tracey BOOK: Beginning Java 2 0 July 24th, 2008 09:33 AM
Web sphere & pps files renee_santoscoi JSP Basics 0 May 24th, 2004 01:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.