[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 01-03-2007, 07:16 AM   #1 (permalink)
zk0
NamePros Member
 
zk0's Avatar
 
Join Date: Jun 2005
Posts: 163
52.70 NP$ (Donate)

zk0 is an unknown quantity at this point


Help! Java: Signatures and Method HELP

I need help with this Java code!

I want to count the numbers in the main using the code in the class MyMath. But I dont really understand how? This is what I have done so far but it's not correctly performed and it doesnt count the last line from the main:

Code:
System.out.println(MyMath.add(123, 6.54));
THE CODE:

Code:
package your_username;

public class Program
{
	public static void main(String[] args)
	{
		int intSum = MyMath.add(123, 456);
		System.out.println(intSum);
		
		double doubleSum = MyMath.add(9.87, 6.54);
		System.out.println(doubleSum);

		System.out.println(MyMath.add(123, 6.54));
	}
}

class MyMath
{

	public static int add(int i, int j) {
		System.out.println(">>> metoden med signaturen add(int, int) har anropats <<<");
		return (123+456); // 
	}

	public static double add(double d, double e) {
		System.out.println(">>> metoden med signaturen add(double, double) har anropats <<<");
		return (9.87+6.54); 
	}

}
Thanks for any help in advance!
zk0 is offline  
Old 01-03-2007, 09:12 AM   #2 (permalink)
NamePros Member
 
Join Date: May 2006
Posts: 160
81.00 NP$ (Donate)

TwistMyArm is on a distinguished road


When you say it doesn't count the last line, what do you mean exactly? Do you mean it's not doing anything, or it's giving you the wrong answer?

I'm assuming you mean the latter and I'm assuming it's because the return values in your class have been hard coded...
TwistMyArm is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 01:35 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85