Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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

Reply With Quote
  #2 (permalink)  
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);
}
}


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:20 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.