Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Find Mean 3 Numbers
Index -> Programming, Java -> Java Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
eNc




PostPosted: Mon Nov 01, 2004 5:22 pm   Post subject: Find Mean 3 Numbers

Hi how do you find the mean of 3 numbers if you can't use if statements, for loops, loops, arrays, basically nothing more advanced than Math.max function.
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Mon Nov 01, 2004 7:18 pm   Post subject: (No subject)

i dont see how any competent programmer can not noe how to do that??? float avg=(num1+num2+num3)/3.0;
wtd




PostPosted: Mon Nov 01, 2004 7:51 pm   Post subject: (No subject)

I think maybe he's talking about "median".

Psuedocode:
code:
max(min(number_1, number2), number_3)
eNc




PostPosted: Mon Nov 01, 2004 9:24 pm   Post subject: (No subject)

omg wtd yea thats wut i meant, ty so much u saved me again!


omg man ure my hero man omg i'm so happy, i have this comp sci test tomrrow and omg i got the scoop on the question and omg! ! ! i was like stuk and u saved me omg ure my hero i'm so happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy Very Happy 20 bits 2 u Razz
zylum




PostPosted: Tue Nov 02, 2004 10:01 pm   Post subject: (No subject)

wtd wrote:
I think maybe he's talking about "median".

Psuedocode:
code:
max(min(number_1, number2), number_3)


i think you meant

code:
min(max(number_1, number_2), number_3)
wtd




PostPosted: Tue Nov 02, 2004 10:27 pm   Post subject: (No subject)

zylum wrote:
wtd wrote:
I think maybe he's talking about "median".

Psuedocode:
code:
max(min(number_1, number2), number_3)


i think you meant

code:
min(max(number_1, number_2), number_3)


Yes, of course, thank you.
eNc




PostPosted: Wed Nov 03, 2004 3:42 pm   Post subject: (No subject)

wtd wrote:
zylum wrote:
wtd wrote:
I think maybe he's talking about "median".

Psuedocode:
code:
max(min(number_1, number2), number_3)


i think you meant

code:
min(max(number_1, number_2), number_3)


Yes, of course, thank you.



well yea slight error but he meant it the other way Razz i'm not an idiot i understood what he ment.
wtd




PostPosted: Wed Nov 03, 2004 3:46 pm   Post subject: (No subject)

eNc wrote:
i'm not an idiot


But I am! Smile
Sponsor
Sponsor
Sponsor
sponsor
eNc




PostPosted: Wed Nov 03, 2004 7:20 pm   Post subject: (No subject)

wtd wrote:
eNc wrote:
i'm not an idiot


But I am! Smile



I DISAGREE
rizzix




PostPosted: Wed Nov 03, 2004 7:24 pm   Post subject: (No subject)

haha.. now think about this.. if a person says he's an idiot.. you should never disagree.. by disagreeing you have acknowledge your self more of an idiot than he/she is.. so you should always agree Laughing LOL
Hikaru79




PostPosted: Thu Nov 04, 2004 7:38 am   Post subject: (No subject)

eNc wrote:
i have this comp sci test tomrrow and omg i got the scoop on the question and omg! ! !


Confused Probably not a good idea to say that aloud. Especially not on a forum that a few teachers lurk around on.
McKenzie




PostPosted: Thu Nov 04, 2004 12:42 pm   Post subject: (No subject)

I hate to extend an already overdone topic ... but
code:
min(max(number_1, number_2), number_3)

???
min(max(5,10),0) is 0
and clearly median is 5. Wink
bugzpodder




PostPosted: Thu Nov 04, 2004 1:01 pm   Post subject: (No subject)

median=a+b+c-(a>=b&&a>=c?aSadb>=a&&b>=c?b:c))-(a<=b&&a<=c?aSadb<=a&&b<=c?b:c));

equilvalently,

median=a+b+c-Math.Max(Math.Max(a,b),c)-Math.Min(Math.Min(b,c),a);
wtd




PostPosted: Thu Nov 04, 2004 2:58 pm   Post subject: (No subject)

McKenzie wrote:
I hate to extend an already overdone topic ... but
code:
min(max(number_1, number_2), number_3)

???
min(max(5,10),0) is 0
and clearly median is 5. Wink


Yes, we covered this. I'm a moron. Smile
eNc




PostPosted: Thu Nov 04, 2004 5:51 pm   Post subject: (No subject)

Hikaru79 wrote:
eNc wrote:
i have this comp sci test tomrrow and omg i got the scoop on the question and omg! ! !


Confused Probably not a good idea to say that aloud. Especially not on a forum that a few teachers lurk around on.


my teach doens' t know about his... yet
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 17 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: