Results 1 to 20 of 37
- 10-15-2010, 07:19 AM #1RanLineR Guest
Working with Methods Can anyone help?
Activity3 working with methods
Sample
Enter an integer value: -9
Enter and integer value: 2
Enter a double value: 3.8
Enter first string : Anna
Enter second string : anna
The Absolute value of -9 is 9
The square root of 9 is 3.0
9 raise to 2 is equivalent to 81.0
The floor value of 3.58 is 3.0
The ceil value of 3.58 is 4.0
Anna is Equivalent to anna
this sample output needs to be the same with my work.
Sample:
int x =-9
result = Math.abs(x);
system.out.println("the absolute value of" +x+" is " +result);
this is what hint they give me.
i dont really understand what will i do in order to get the method.
:(
import java.io.*;
public class Activity4{
public static void main (String args[])throws IOException{
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
what next?? thanks~!
- 10-15-2010, 07:21 AM #2RanLineR Guest
and somebody said that i can work easier using JOption?
- 10-15-2010, 08:01 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
No of course you can with JOption.
But you've to deals with correct conversions, JOption returns an object of string.
- 10-15-2010, 08:01 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Did you try anything with JOption, show it here if so?
- 10-15-2010, 09:14 AM #5RanLineR Guest
they said JOption is much easier to use, could you give me some sample?
- 10-15-2010, 09:22 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Try to understand above.Java Code:String ans = JOptionPane.showInputDialog("Enter an integer value:"); int iVal = Integer.parseInt(ans);
- 10-15-2010, 09:35 AM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,379
- Blog Entries
- 7
- Rep Power
- 17
- 10-15-2010, 09:38 AM #8RanLineR Guest
sir can you do the the absolute value of" +x+" is " +result); ?
- 10-15-2010, 09:52 AM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Please don't ask people to do your homework for you.
- 10-15-2010, 10:12 AM #10RanLineR Guest
im just asking how to use that code because im new to it.
- 10-15-2010, 10:14 AM #11
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 10-15-2010, 10:15 AM #12
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 10-15-2010, 10:15 AM #13RanLineR Guest
okay thanks by the way.much appreciated =)
- 10-15-2010, 10:17 AM #14RanLineR Guest
yep a little. as i said im a begginer.
- 10-15-2010, 10:18 AM #15
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
If you don't want to learn from what we say, I'm sure it's not encourage us to helping you out.
- 10-15-2010, 10:20 AM #16
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 10-15-2010, 10:21 AM #17RanLineR Guest
what do you mean sir?
- 10-15-2010, 10:23 AM #18RanLineR Guest
yes sir =))))
- 10-15-2010, 10:31 AM #19
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You ask a question here, and we all comment on you. Actually I gave you a simple code segments, and I ask you to try to understand it. Why I'm said that is, without experimenting something ourselves we can't learn a lot. Experience make a big difference. :)
What you've done is without doing that you ask another question. That's not good.
- 10-15-2010, 10:49 AM #20RanLineR Guest
Similar Threads
-
Trouble with static methods and boolean equals() methods with classes
By dreamingofgreen in forum New To JavaReplies: 8Last Post: 04-16-2012, 11:00 PM -
Working with Methods
By besweeet in forum New To JavaReplies: 5Last Post: 03-25-2010, 05:33 PM -
How to get methods to see variables in other methods
By ejs7597 in forum New To JavaReplies: 4Last Post: 04-03-2009, 06:36 AM -
Java mail problem(working in intranet,but not working in iternet)
By sundarjothi in forum Advanced JavaReplies: 8Last Post: 05-28-2008, 07:00 AM -
Static methods - not working
By Echilon in forum New To JavaReplies: 2Last Post: 12-21-2007, 01:31 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks