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

Beginner Help

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.

chihwei
Newbie Poster
5 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

How about asking a specific question and showing the code you have written. Otherwise we aren't going to do your homework for you.

stymiee
He's No Good To Me Dead
Moderator
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
 

Sorry ...first time post

the code i wrote :
==============
class Telephone{
String number ;
static int quantity;
static double total;
static String makeFullNumber(){
return quantity+"- "+n;
}
}
========
i don't how come it can't find the makeFullNumber ?

chihwei
Newbie Poster
5 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

access modifiers...

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

Ok.
I think you forgot the public keyword. Maybe you should declare your method like this:

public static String makeFullNumber(String aNumber, int aCode)
{
    return aNumber + " - " + aCode;
}
Chaster
Junior Poster in Training
68 posts since Jun 2007
Reputation Points: 12
Solved Threads: 3
 

Writing "public " (Access- Modifiers ) , is not the error here .The class can be written with out it and it will be friendly by default (Can be Accessed inside the same package ) ??:icon_exclaim:

msi_333
Newbie Poster
22 posts since Jun 2007
Reputation Points: 10
Solved Threads: 4
 

don't go rambling about things you don't understand...

The fact that you end your statement with several question marks means you shouldn't have made it...

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

"you don't understand..." :@ it is not good to say that for a one u don't know anything about him , just the user name . and the questions marks it was my mistake , and as u see also i put big wondering notations,

thanks

msi_333
Newbie Poster
22 posts since Jun 2007
Reputation Points: 10
Solved Threads: 4
 
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.



it's an instance variable, add private before you declare String :)

ProgrammersTalk
Junior Poster in Training
84 posts since Jun 2007
Reputation Points: 21
Solved Threads: 7
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You