d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Iso Help With A Java Prob
Prev1234Next
Add Reply New Topic New Poll
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Oct 1 2014 11:20pm
Quote (Jibbosh @ Oct 2 2014 12:16am)
Well, my idea about that is to get NbMax the lowest  .. number possible if you don't go in the negative...

So if I enter a number after that, it will for sure take the place of iNbMax..

so if I enter "6"

iNbMax will be equal to  6 until a new higher number takes his place.


He is saying you have two numbers to choose from as your max. You just want to find the largest of the two. Therefore set your max to be one of them (choose whichever one you fancy) and then compare them. If the other is larger, set that as your max. Setting the max to be 0 requires you to have an extra else clause on that comparison which is not needed if you initalize your max to be one of the two inputs.
Member
Posts: 6,604
Joined: May 29 2013
Gold: 2.72
Oct 1 2014 11:36pm
Quote (Minkomonster @ Oct 2 2014 01:20am)
He is saying you have two numbers to choose from as your max. You just want to find the largest of the two. Therefore set your max to be one of them (choose whichever one you fancy) and then compare them. If the other is larger, set that as your max. Setting the max to be 0 requires you to have an extra else clause on that comparison which is not needed if you initalize your max to be one of the two inputs.


Well.. you mean if I input 2 numbers, and I would have to input always the highest one first?

If that's what you mean, I can't do that, my teacher does the tests and she just enters them in random orders.
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Oct 1 2014 11:39pm
Quote (Jibbosh @ Oct 2 2014 12:36am)
Well.. you mean if I input 2 numbers, and I would have to input always the highest one first?

If that's what you mean, I can't do that, my teacher does the tests and she just enters them in random orders.


No dude, we are past input, you already have them at this point you have input 2 numbers

Code

int input1, input2;


Your job is to find which is the highest and which is the smallest

Code

int largest, smallest;


Given what carteblanche and myself have recommended, how would you do that?
Member
Posts: 6,604
Joined: May 29 2013
Gold: 2.72
Oct 1 2014 11:58pm
Well. I guess I could do.

Code
if ( input1<input2 )
smallest = input1;
largest = input2
else
smallest = input2
largest = input1
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Oct 2 2014 12:02am
Yea, that definitely works. Now take a look back at carteblanche's previous post and see how you can use smallest and largest to put together a for loop that will allow you to print out largest, smallest times.
Member
Posts: 6,604
Joined: May 29 2013
Gold: 2.72
Oct 2 2014 12:08am
Quote (Minkomonster @ Oct 2 2014 02:02am)
Yea, that definitely works. Now take a look back at carteblanche's previous post and see how you can use smallest and largest to put together a for loop that will allow you to print out largest, smallest times.


Alright, thanks to both of ya, sorry if im slow at understanding. It's 2 : 00 am and im pretty tired and can't wait to be done.
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Oct 2 2014 12:12am
Quote (Jibbosh @ Oct 2 2014 01:08am)
Alright, thanks to both of ya, sorry if im slow at understanding. It's 2 : 00 am and im pretty tired and can't wait to be done.


Don't apologize for being slow. You're learning. Don't ever apologize for learning. Go at your own pace.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 2 2014 12:14am
Quote (Minkomonster @ Oct 2 2014 02:12am)
Don't apologize for being slow. You're learning. Don't ever apologize for learning. Go at your own pace.


you can apologize for starting at the last minute, though. but don't apologize to us; apologize to yourself.

the less you understand, the sooner you start and the more you practice.

This post was edited by carteblanche on Oct 2 2014 12:14am
Member
Posts: 6,604
Joined: May 29 2013
Gold: 2.72
Oct 2 2014 12:22am
Quote (carteblanche @ Oct 2 2014 02:14am)
you can apologize for starting at the last minute, though. but don't apologize to us; apologize to yourself.

the less you understand, the sooner you start and the more you practice.


Well I started like 1 month ago max, and we only have 3 hours per week in programming which isn't much.

But yeah I know ... last minute, im used to do homeworks like that, and it's my problem but I don't mind having little of sleep, if I get my things done in time, im cool with that.
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Oct 2 2014 12:26am
Quote (Jibbosh @ Oct 2 2014 01:22am)
Well I started like 1 month ago max, and we only have  3 hours per week in programming which isn't much.

But yeah I know ... last minute, im used to do homeworks like that, and it's my problem but I don't mind having little of sleep, if I get my things done in time, im cool with that.


Its the equivalent of cramming. It doesn't do you any good other than securing a meaningless mark on a report card. You don't retain information thoroughly.
Go Back To Programming & Development Topic List
Prev1234Next
Add Reply New Topic New Poll