[Show all top banners]

zeePa
Replies to this thread:

More by zeePa
What people are reading
Subscribers
Subscribers
[Total Subscribers 1]

paroo
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 Small java challenge
[VIEWED 7061 TIMES]
SAVE! for ease of future access.
Posted on 10-13-08 3:10 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

This is small java challenge to all java beginners, and pros. Well i am trying to do it and not yet being able to work it out!

Let me see if you can get it to work...

 "Write overloaded Java methods that return the difference of two parameters. Your methods should contain the logic to return the difference of the larger parameter – smaller parameter, regardless of parameter order. Provide enough test code to ensure your methods are logically correct. The following table displays the required method parameter variations.

 
Parm 1 Type              Parm 2 Type                           Return Type
int                                      int                                         Int
double                            double                                    double
int                                   double                                    double
double                                int                                       double

Continue to properly document your source code."

 




 
Posted on 10-13-08 3:13 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

what part r u stuck @? what does your pseudo code look like?

 
Posted on 10-13-08 5:10 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

I am new to java myself, not Sure if it has templetes.

If it was C++ you can make one Templete instad of overloading function with variaty of parameters.
If you start writing functions ( or methods) the possible combinations of parameters can be quite high, and redundant.

I like the cast but then again the question asks for difference, ( which might get messed up because of loss of data). Hope someone can come up with solution.

P.S If its just int and double, there are only four Methods to be written, which should be a no brainier.

 
Posted on 10-13-08 5:16 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Its better to post ur queries related to java in java forum... the url is java-forums.org.. u'll get perfect guidance...
 
Posted on 10-13-08 5:49 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Hope you know what function overloading is. Here are the declarations for overloaded method diff().  This is just to give you a start. Define these functions, test the defined functions from the main with different parameters.
public int diff(int a , int b, int c);
public double diff(double a, double b, double c);
public double diff(int a, double b, double c);
public double diff(double a, int b, double c);



Post your code. If you are stuck somewhere.

PS: Use some IDE like Eclipse or Netbeans  that will save ur time.
Last edited: 13-Oct-08 05:50 PM

 
Posted on 10-13-08 6:00 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Thanks Suike for the info on Generics. I will do  some more research.. but why do you say careful with login ID ?

Also, why dont people Google for stuffs. and with all due respect, I don't think our fellow Nepalis know about other forums besides Sajha

 
Posted on 10-13-08 10:58 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Suike you are scaring me dude, I have hardly had 20 posts in Sajha, and this nick yellow. I have not used anywhere. and yet you know who I am.

Not just programing skills, you have some serious social engineering skillz.

*bows*

Now How do I find out who you are. ( how to send Msg in this forum)
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 365 days
Recommended Popular Threads Controvertial Threads
शीर्षक जे पनि हुन सक्छ।
डीभी परेन भने खुसि हुनु होस् ! अमेरिकामाधेरै का श्रीमती अर्कैसँग पोइला गएका छन् !
What are your first memories of when Nepal Television Began?
Sajha Poll: नेपालका सबैभन्दा आकर्षक महिला को हुन्?
ChatSansar.com Naya Nepal Chat
NRN card pros and cons?
TPS Re-registration case still pending ..
Basnet or Basnyat ??
TPS Re-registration
निगुरो थाहा छ ??
Nas and The Bokas: Coming to a Night Club near you
Toilet paper or water?
Anybody gotten the TPS EAD extension alert notice (i797) thing? online or via post?
अमेरिकामा छोरा हराएको सूचना
ढ्याउ गर्दा दसैँको खसी गनाउच
Sajha Poll: Who is your favorite Nepali actress?
Do nepalese really need TPS?
Problems of Nepalese students in US
nrn citizenship
TPS EAD auto extended to June 2025 or just TPS?
Nas and The Bokas: Coming to a Night Club near you
Mr. Dipak Gyawali-ji Talk is Cheap. US sends $ 200 million to Nepal every year.
TPS Update : Jajarkot earthquake
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters