954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

definition of a method

hi everyone i need some help with java..:sad:

Write the definition of a method twice , which receives an integer parameter and returns an integer that is twice the value of the parameter.

and

Write the definition of a class Telephone . The class has no constructors, one instance variable of type String called number , and two static variables. One is of type int called quantity ; the other is of type double called total . Besides that, the class has one static method makeFullNumber . The method accepts two arguments, a String containing a telephone number and an int containing an area code. The method concatenates the two arguments in the following manner: First comes the area code, then a dash, then the telephone number. The method returns the resultant string.


i'm so lost...please help... :eek:

THK
Newbie Poster
15 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

Is there a specific question about this homework assignment? What concepts are you having a hard time with? You won't learn much if you have someone else do your coding for you.

Andy

nicentral
Junior Poster
166 posts since Apr 2005
Reputation Points: 14
Solved Threads: 5
 
hi everyone i need some help with java..:sad: Write the definition of a method twice , which receives an integer parameter and returns an integer that is twice the value of the parameter. and Write the definition of a class Telephone . The class has no constructors, one instance variable of type String called number , and two static variables. One is of type int called quantity ; the other is of type double called total . Besides that, the class has one static method makeFullNumber . The method accepts two arguments, a String containing a telephone number and an int containing an area code. The method concatenates the two arguments in the following manner: First comes the area code, then a dash, then the telephone number. The method returns the resultant string. i'm so lost...please help... :eek:

Please try to code something otherwise we can't help. Daniweb homework policy. ThanQ.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

public type method(){
method = method*2;
return this.method;
}

this is what i had.....but its wrong.. :(

THK
Newbie Poster
15 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

Yours:

public type method(){ 
  method = method*2; 
  return this.method; 
}

Correct

public int method(int value){ 
  return value * 2; 
}

Compare

Your description saidtakes an integer argument
returns an integer
returned int is double the parameter

The only thing your method had was the "* 2" and nothing else.

I think you need to review everything you have covered in your class so far. And then continue on with the Telephone class.

masijade
Industrious Poster
Moderator
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You