![]() |
| ||
| Re: Need help with max/min'ing multiply Quote:
Quote:
You want to check the statement not assign value... if(input == 0){ |
| ||
| Re: Need help with max/min'ing multiply Quote:
still, the ; shouldn't have been there |
| ||
| Re: Need help with max/min'ing multiply In my opinion this is a better way to do that, in looping you would have to customise the loop in a way that it runs only for set of values that you need for e.g. no repitition of the digits etc this way you would have to take care of a lot of conditions which would make the code complex. Hence I say that the method shown above would be a more cleaner convenient option. Also since the repetition is not allowed you actually have lesser combination of digits to evaluate so that you can write out all the combinations by hand (which I guess won't be more than 4-6) |
| ||
| Re: Need help with max/min'ing multiply Okay I'm kind of stuck on this if-else statement. I chose to just give the correct ones directly, since looping would be too difficult to fabricate. Right now I get an error "else without if" for: if(input == 0){ |
| ||
| Re: Need help with max/min'ing multiply if(input == 0){remove one of the {'s and also: re-check what you're doing here: else(input == 1); |
| ||
| Re: Need help with max/min'ing multiply Thanks for the help, and someone told me that I should use the (input == #); over what I had to eliminate an error. This was to read the input from the user to determine if they want to find the highest or lowest product. I'm going to revise this program completely this weekend so that it tests every possibility completely since I have no clue how I should fabricate it within a loop. If there were a way to switch the integers n1, n2, n3 with the initial tens value for either, I could use a loop; however, I'm new to java (more of a VB guy) and am unaware as to how to do such a thing. If I were to code it, it would end up being very unorthodox as most of my programs do. |
| ||
| Re: Need help with max/min'ing multiply Quote:
yes: you do need to do if(input == valueToCheck)if it are integers, since you want to compare the value to equality and they're not Objects. no: you do not want to put the ';' straight after the if. what happens if what is between the brackets is true, is what is behind the if statement, until the first ';' if there are no '{ }' so, if you would check it like that, and put the ';', you would automatically run the next lines, if the statement was true or not, since the next lines are not dependent on the if. |
| ||
| Re: Need help with max/min'ing multiply if(input == 0){I don't think this approach would always work. E.g. 96*85*74 = 603840 whereas 76*85*94 = 607240 you will have to try out all possible combinations of them and then check for the maximum among them as shown by me in post #6 |
| ||
| Re: Need help with max/min'ing multiply Quote:
|
| ||
| Re: Need help with max/min'ing multiply thats for him to remove, I just copied the code he has pasted a couple posts above in the thread. Its certainly not my job. |
| All times are GMT -4. The time now is 7:03 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC