Welcome to Dream.In.Code
Getting Java Help is Easy!

Join 136,413 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,444 people online right now. Registration is fast and FREE... Join Now!




I don't get this.

 
Reply to this topicStart new topic

I don't get this., log 10

Ephemeralz
14 Oct, 2008 - 11:16 PM
Post #1

New D.I.C Head
*

Joined: 11 Sep, 2008
Posts: 18



Thanked: 1 times
My Contributions
I'm supposed to write a class, where one of the instance variable is the distance of a star. Here's what it says in the question: The instance variable logdist is distance (taking log10) in meters.

When I print it out, its supposed to be something like 9.19e+17 meters. The question says: When you print it out, ypu need to use the Math class because distance are given in logarithmic(log base 10) scale.

I don't get what the question is saying!

I know for sure 9.19e+17 means 9.19*10 to the power of 17, but what should I use for the instance variable?

I'm not looking for a code or something, just an example of what value I should put in the instance variable part.


User is offlineProfile CardPM
+Quote Post

g00se
RE: I Don't Get This.
15 Oct, 2008 - 12:19 AM
Post #2

D.I.C Regular
Group Icon

Joined: 19 Sep, 2008
Posts: 455



Thanked: 38 times
My Contributions
You need something like the following ('distance' would be the 'raw' distance):

CODE

public double getDistance() {
    return Math.log10(distance);
}

User is offlineProfile CardPM
+Quote Post

Ephemeralz
RE: I Don't Get This.
15 Oct, 2008 - 12:40 AM
Post #3

New D.I.C Head
*

Joined: 11 Sep, 2008
Posts: 18



Thanked: 1 times
My Contributions
QUOTE(g00se @ 15 Oct, 2008 - 01:19 AM) *

You need something like the following ('distance' would be the 'raw' distance):

CODE

public double getDistance() {
    return Math.log10(distance);
}



So you mean my value for logdist will be something like 8674832423.34 meters, and my result is log10(8674832423.34)?

But the qn said that the printed value will be 9.17e+17!

Sorry, but I still don't get it! =(
User is offlineProfile CardPM
+Quote Post

g00se
RE: I Don't Get This.
15 Oct, 2008 - 12:57 AM
Post #4

D.I.C Regular
Group Icon

Joined: 19 Sep, 2008
Posts: 455



Thanked: 38 times
My Contributions
Sorry. Misread it I think. All you need, I think, is something like:

CODE

double actualDist = Math.pow(10, logDist);


If you take, for logDist, something like 17.962369335670022, you will see a value something like your tutor mentioned for 'actualDist'
User is offlineProfile CardPM
+Quote Post

Ephemeralz
RE: I Don't Get This.
15 Oct, 2008 - 10:41 AM
Post #5

New D.I.C Head
*

Joined: 11 Sep, 2008
Posts: 18



Thanked: 1 times
My Contributions
QUOTE(g00se @ 15 Oct, 2008 - 01:57 AM) *

Sorry. Misread it I think. All you need, I think, is something like:

CODE

double actualDist = Math.pow(10, logDist);


If you take, for logDist, something like 17.962369335670022, you will see a value something like your tutor mentioned for 'actualDist'


Hmm, meaning if my distance is 9.19*10^17 meters, my code will be like this?

CODE


private double logdist = 17.962369

public double getlogdist()
{
      return Math.pow(10, logdist)
}

User is offlineProfile CardPM
+Quote Post

g00se
RE: I Don't Get This.
15 Oct, 2008 - 10:47 AM
Post #6

D.I.C Regular
Group Icon

Joined: 19 Sep, 2008
Posts: 455



Thanked: 38 times
My Contributions
Not quite. getlogdist() should be getDistance() since you're returning the actual distance
User is offlineProfile CardPM
+Quote Post

Ephemeralz
RE: I Don't Get This.
15 Oct, 2008 - 07:41 PM
Post #7

New D.I.C Head
*

Joined: 11 Sep, 2008
Posts: 18



Thanked: 1 times
My Contributions
Alright thanks, that sounds right.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 12:35PM

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month