The Artima Developer Community
Sponsored Link

Java Answers Forum
A simple question

22 replies on 2 pages. Most recent reply: Sep 19, 2003 9:04 AM by Joe Parks

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 22 replies on 2 pages [ « | 1 2 ]
Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Re: A simple question Posted: Sep 13, 2003 8:24 AM
Reply to this message Reply
Advertisement
http://www.catb.org/~esr/faqs/smart-questions.html

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: A simple question Posted: Sep 13, 2003 4:21 PM
Reply to this message Reply
> hay matt seems like you too are online now and checkign
> the forums :-)

Yeah, it goes in cycles.

Are you referring to something specific?

Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Re: A simple question Posted: Sep 13, 2003 5:55 PM
Reply to this message Reply
Nothing specific. When I was going to post the answer there your post was not there and once I made the post, you have already posted. So I thought you must have been also checking the forums about the same time :-)

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: A simple question Posted: Sep 13, 2003 6:58 PM
Reply to this message Reply
> can someone help me to make a java program about
> scientific calculator and the funtions are the 0-9,+ - *
> /,clear,sin,cos,tan,the octal and binary conversions
> thanx.i need it before this month ends.

Looks like richard and jocelyn are in the same class.

Anyhow, richard, when you are posting a completely different topic, you ought to start a new thread. In this case, you should just post a "me too" in jocelyn's thread. Unless you are jocelyn (there are suspicious similarties...).

richard

Posts: 3
Nickname: lenard
Registered: Sep, 2003

Re: A simple question Posted: Sep 17, 2003 1:31 AM
Reply to this message Reply
were not at the same class,i think accidentally that we are the same on our problem.maybe her problem is all about a simple calculator,but for mine it was a scientific.pls can you send me a java program about scientific calculator before this month ends?thanx

David

Posts: 150
Nickname: archangel
Registered: Jul, 2003

Re: A simple question Posted: Sep 17, 2003 8:00 AM
Reply to this message Reply
What problem are you having at the moment?

gratiartis

Posts: 8
Nickname: gratiartis
Registered: Sep, 2003

Re: A simple question Posted: Sep 17, 2003 8:56 AM
Reply to this message Reply
> while (str != null) {
> System.out.print("> prompt ");
> str = in.readLine();
> process(str);

> what do i put where it says process so that i can read
> specific words in a text file.

It looks as though you are reading from the file line by line. Keeping things simple, I'll assume that you have a text file containing comma separated values. Hence a line might look like:

12,3,68,83,2,88,39

You have just created a String (str = "12,3,68,83,2,88,39") based on the contents of this line. In your 'process' method you can then use the 'split' method of the String class. Note that this 'split' method is recent (since 1.4), so if you are working with an earlier version of the JDK then you should use StringTokenizer for the same job. The following is a trivial example of how to use each of these:

// Initial value of String
String str = "12,3,68,83,2,88,39" ;
System.out.println( "Initial String=\"" + str + "\"" ) ;
 
// Using String.split()
String[] items = str.split( "," ) ;
for ( int i = 0 ; i < items.length ; i++ )
    System.out.println( "items[" + i + "]=" + items[i]  ) ;
 
// Using StringTokenizer
StringTokenizer st = new StringTokenizer( str, "," ) ;
String[] tokenizedItems = new String[ st.countTokens() ] ;
int j = 0 ;
while ( st.hasMoreTokens() ) {
    tokenizedItems[j] = st.nextToken() ;
    j++ ;
}
for ( int i = 0 ; i < tokenizedItems.length ; i++ )
    System.out.println( "tokenizedItems[" + i + "]=" + tokenizedItems[i]  ) ;

Joe Parks

Posts: 107
Nickname: joeparks
Registered: Aug, 2003

Re: A (no longer) simple question Posted: Sep 19, 2003 9:04 AM
Reply to this message Reply
For the scientific calculator problem, I would first list all of the calculations that I need to support. It seems you've done that (or, rather, your instructor did).

Next, I would attempt to implement each of these in a simple console application. Fortunately, the java.lang.Math object has done most of the work for you.

Finally, I would create a JFrame with an appropriate layout (GridLayout, perhaps?) and add buttons with ActionListeners to call the functions defined in step 2 to read from and update a JTextField.

I suspect that the detailed hints for each of these steps is in this month's reading assignment(s).

Flat View: This topic has 22 replies on 2 pages [ « | 1  2 ]
Topic: jini: how much harm does the scsl? Previous Topic   Next Topic Topic: mouse clicked

Sponsored Links



Google
  Web Artima.com   

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