The Artima Developer Community
Sponsored Link

Java Answers Forum
Logarithms Please Help!

5 replies on 1 page. Most recent reply: Nov 20, 2003 1:09 AM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
Karas

Posts: 3
Nickname: kabilliu
Registered: Nov, 2003

Logarithms Please Help! Posted: Nov 18, 2003 2:19 AM
Reply to this message Reply
Advertisement
I am beginner of Java. I would like to make a console application that I can input the kind of logarithm and the value, then I get the result
Using class Math with the static method log(double a)

Thank you in advance


Tanya

Posts: 16
Nickname: seabeck
Registered: Nov, 2003

Re: Logarithms Please Help! Posted: Nov 18, 2003 9:09 AM
Reply to this message Reply
If you are trying to get the integer values and you are using a console/container.

I think you can use the JTextField and have an actionListener for a button that when it is clicked will read in the b and the a of the log and then you just capture those and change them to integers using parseInt then pass in b and a to your Math method and then return the answer in a JTextArea.

I don't know if you are using swing to make your container/console. If so that is the way I would do it.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Logarithms Please Help! Posted: Nov 18, 2003 10:53 PM
Reply to this message Reply
"Console app" means no gui, so I would guess that using Swing is not an option. To read the input in this case, you'll probably want to use System.in. Additionally, if you want to have conveniences like reading lines, you can wrap it in a BufferedReader, like this:
BufferedReader input = new BufferedReader( new InputStreamReader(System.in) );

Then you can later do stuff like this:
System.out.println( "Type a number followed by the Enter key: " );
n = Integer.parseInt(input.readLine());

(of course, it might be a good idea to have some graceful error handling for junky input).

Anit

Posts: 1
Nickname: anii
Registered: Nov, 2003

Re: Logarithms Please Help! Posted: Nov 19, 2003 1:04 AM
Reply to this message Reply
> I am beginner of Java. I would like to make a console
> application that I can input the kind of logarithm and the
> value, then I get the result
> Using class Math with the static method log(double a)
>
> Thank you in advance

fdgfdgfdgfdg

Tanya

Posts: 16
Nickname: seabeck
Registered: Nov, 2003

Re: Logarithms Please Help! Posted: Nov 19, 2003 8:59 PM
Reply to this message Reply
Thanks Matt for correcting me and helping them out! :)

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Logarithms Please Help! Posted: Nov 20, 2003 1:09 AM
Reply to this message Reply
Sure thing; he can come back and use you suggestions too, toward the end of the semester when they get to the GUI/Swing stuff!

Flat View: This topic has 5 replies on 1 page
Topic: Java scrolling problem (JScrollPane) Previous Topic   Next Topic Topic: Radix sort

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use