-
Java (
http://www.daniweb.com/forums/forum9.html)
| IMtheBESTatJAVA | Dec 9th, 2008 8:59 am | |
| Re: Need help with max/min'ing multiply I'm going to reformat this in a new manner:
Going to go to the high if as i had before, try all combos, then print highest result.
Then I'll go to the low and do the same with the least. I will repost the reformatted code soon. |
| verruckt24 | Dec 9th, 2008 9:07 am | |
| Re: Need help with max/min'ing multiply Thats what I have been suggesting you since a long while ago. |
| IMtheBESTatJAVA | Dec 12th, 2008 9:44 am | |
| Re: Need help with max/min'ing multiply No need to be haughty; I'm just trying to follow curriculum to the best of my ability. Now I'm going to have to devise a makeshift program over an array or loop. Here's what I have changed, trying every combination possible and printing the actual already-known highest and lowest based on output.
public class Powers
{
public static void main(String[] args){
ConsoleIO console = new ConsoleIO();
int input;
int numOneTensLow = 10;
int numTwoTensLow = 20;
int numThreeTensLow = 30;
int numOneOnesLow = 4;
int numTwoOnesLow = 5;
int numThreeOnesLow = 6;
int numOneTensHigh = 90;
int numTwoTensHigh = 80;
int numThreeTensHigh = 70;
int numOneOnesHigh = 6;
int numTwoOnesHigh = 5;
int numThreeOnesHigh = 4;
int numOneLowOne = numOneTensLow + numOneOnesLow;
int numTwoLowOne = numTwoTensLow + numTwoOnesLow;
int numThreeLowOne = numThreeTensLow + numThreeOnesLow;
int numOneHighOne = numOneTensHigh + numOneOnesHigh;
int numTwoHighOne = numTwoTensHigh + numTwoOnesHigh;
int numThreeHighOne = numThreeTensHigh + numThreeOnesHigh;
int numOneLowTwo = numOneTensLow + numOneOnesLow;
int numTwoLowTwo = numTwoTensLow + numThreeOnesLow;
int numThreeLowTwo = numThreeTensLow + numTwoOnesLow;
int numOneHighTwo = numOneTensHigh + numOneOnesHigh;
int numTwoHighTwo = numTwoTensHigh + numThreeOnesHigh;
int numThreeHighTwo = numThreeTensHigh + numTwoOnesHigh;
int numOneLowThree = numOneTensLow + numTwoOnesLow;
int numTwoLowThree = numTwoTensLow + numOneOnesLow;
int numThreeLowThree = numThreeTensLow + numThreeOnesLow;
int numOneHighThree = numOneTensHigh + numTwoOnesHigh;
int numTwoHighThree = numTwoTensHigh + numOneOnesHigh;
int numThreeHighThree = numThreeTensHigh + numThreeOnesHigh;
int numOneLowFour = numOneTensLow + numTwoOnesLow;
int numTwoLowFour = numTwoTensLow + numThreeOnesLow;
int numThreeLowFour = numThreeTensLow + numOneOnesLow;
int numOneHighFour = numOneTensHigh + numTwoOnesHigh;
int numTwoHighFour = numTwoTensHigh + numThreeOnesHigh;
int numThreeHighFour = numThreeTensHigh + numOneOnesHigh;
int numOneLowFive = numOneTensLow + numThreeOnesLow;
int numTwoLowFive = numTwoTensLow + numOneOnesLow;
int numThreeLowFive = numThreeTensLow + numTwoOnesLow;
int numOneHighFive = numOneTensHigh + numThreeOnesHigh;
int numTwoHighFive = numTwoTensHigh + numOneOnesHigh;
int numThreeHighFive = numThreeTensHigh + numTwoOnesHigh;
int numOneLowSix = numOneTensLow + numThreeOnesLow;
int numTwoLowSix = numTwoTensLow + numTwoOnesLow;
int numThreeLowSix = numThreeTensLow + numOneOnesLow;
int numOneHighSix = numOneTensHigh + numThreeOnesHigh;
int numTwoHighSix = numTwoTensHigh + numTwoOnesHigh;
int numThreeHighSix = numThreeTensHigh + numOneOnesHigh;
int lowproductone = (numOneLowOne * numTwoLowOne * numThreeLowOne);
int highproductone = (numOneHighOne * numTwoHighOne * numThreeHighOne);
int lowproducttwo = (numOneLowTwo * numTwoLowTwo * numThreeLowTwo);
int highproducttwo = (numOneHighTwo * numTwoHighTwo * numThreeHighTwo);
int lowproductthree = (numOneLowThree * numTwoLowThree * numThreeLowThree);
int highproductthree = (numOneHighThree * numTwoHighThree * numThreeHighThree);
int lowproductfour = (numOneLowThree * numTwoLowThree * numThreeLowThree);
int highproductfour = (numOneHighFour * numTwoHighFour * numThreeHighFour);
int lowproductfive = (numOneLowFive * numTwoLowFive * numThreeLowFive);
int highproductfive = (numOneHighFive * numTwoHighFive * numThreeHighFive);
int lowproductsix = (numOneLowSix * numTwoLowSix * numThreeLowSix);
int highproductsix = (numOneHighSix * numTwoHighSix * numThreeHighSix);
System.out.println("This program will calculate three two-digit" +
" numbers that create the lowest and highest possible products " +
"using the numbers 1 through 9 once in each.");
System.out.println("To calculate the highest input 1, to calculate" +
" the lowest, input 0: ");
input = console.readInt();
if(input == 0){
{
System.out.println(lowproductone);
System.out.println(lowproducttwo);
System.out.println(lowproductthree);
System.out.println(lowproductfour);
System.out.println(lowproductfive);
System.out.println(lowproductsix);
}
else(input == 1);
System.out.println(highproductone);
System.out.println(highproducttwo);
System.out.println(highproductthree);
System.out.println(highproductfour);
System.out.println(highproductfive);
System.out.println(highproductsix);
}
}}}}
Right now I'm getting an error for having an "else without if", and was hoping someone could help me out. Thanks for the help. I still need to add the printing of the statement of what the highest/lowest combos actually are, but I'll add it once I get the if statement to work. |
| javaAddict | Dec 12th, 2008 10:33 am | |
| Re: Need help with max/min'ing multiply I hope that you realize that this is wrong:
if(input == 0){
{
}
else(input == 1);
}
You should have this:
if (input==0) {
} else {
}OR:
if (input==0) {
} else if (input==1) {
} else {
} |
| verruckt24 | Dec 12th, 2008 12:17 pm | |
| Re: Need help with max/min'ing multiply Quote: Originally Posted by IMtheBESTatJAVA (Post 755739) No need to be haughty | I think you need to show more courtesy to the fellow who's trying to help for long. You are showing me the same solution here that I had hinted to you ages earlier (take a closer look at my previous posts and try to understand them, cause I know you sure haven't) and that's what I meant from my previous post. I do not know which curriculum you are trying to follow by not taking the hints and not reaching the solution at the earliest. |
| IMtheBESTatJAVA | Dec 15th, 2008 9:01 am | |
| Re: Need help with max/min'ing multiply Snobbish remarks with assistance doesn't justify your self-righteousness, veruckt24. I know you're making a conscious decision to help me with this and I am very appreciative, but to become upset over the fact that I didn't take your advice right away on an open forum when I have so many projects moving through me is just plain annoying to me. Thank you for the proper formatting on the if-else statement though. I am sorry I can not determine between a 'good' or 'bad' post, but when changing code you must realize that taking every forum and members thereof in advice can suffice to a mutlitude of mishaps if I were to take everyone's suggestions or changes. |
| verruckt24 | Dec 15th, 2008 9:27 am | |
| Re: Need help with max/min'ing multiply I am not even asking you to take my advice and I simply don't need to, I have given it and now it's upto you whether to take it or not. It's not that I am to benefit or something from that. What I just had remarked about was that the solution you told me you were implementing had been hinted by me quiet a while ago already.
To that you replied, that I was being haughty which is certainly not going to liked by anyone as far as I know.
And if it's annoying I wasn't the one requesting for help in the first place. This is complete ingrateful nature which I assume from your bad rep has been already noted by many. |
| All times are GMT -4. The time now is 1:20 am. | |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC