943,769 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1826
  • Java RSS
Jun 11th, 2007
0

Beginner Help

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chihwei is offline Offline
5 posts
since Jun 2007
Jun 11th, 2007
0

Re: Beginner Help

How about asking a specific question and showing the code you have written. Otherwise we aren't going to do your homework for you.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Jun 11th, 2007
0

Re: Beginner Help

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 ?
Last edited by chihwei; Jun 11th, 2007 at 11:14 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chihwei is offline Offline
5 posts
since Jun 2007
Jun 12th, 2007
0

Re: Beginner Help

access modifiers...
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Jun 15th, 2007
0

Re: Beginner Help

Ok.
I think you forgot the public keyword. Maybe you should declare your method like this:
Java Syntax (Toggle Plain Text)
  1. public static String makeFullNumber(String aNumber, int aCode)
  2. {
  3. return aNumber + " - " + aCode;
  4. }
Reputation Points: 12
Solved Threads: 3
Junior Poster in Training
Chaster is offline Offline
68 posts
since Jun 2007
Jun 15th, 2007
0

Re: Beginner Help

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 ) ??
Reputation Points: 10
Solved Threads: 4
Newbie Poster
msi_333 is offline Offline
22 posts
since Jun 2007
Jun 16th, 2007
0

Re: Beginner Help

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...
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Jun 16th, 2007
0

Re: Beginner Help

"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
Reputation Points: 10
Solved Threads: 4
Newbie Poster
msi_333 is offline Offline
22 posts
since Jun 2007
Jun 17th, 2007
0

Re: Beginner Help

Click to Expand / Collapse  Quote originally posted by chihwei ...
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
Reputation Points: 21
Solved Threads: 7
Junior Poster in Training
ProgrammersTalk is offline Offline
83 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: how to call a method defined in another file?
Next Thread in Java Forum Timeline: help w/ images on buttons





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC