| | |
Need help with max/min'ing multiply
![]() |
•
•
Join Date: Oct 2008
Posts: 37
Reputation:
Solved Threads: 0
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.
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.
Java Syntax (Toggle Plain Text)
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.
Last edited by IMtheBESTatJAVA; Dec 12th, 2008 at 9:46 am.
I hope that you realize that this is wrong:
You should have this:
OR:
Java Syntax (Toggle Plain Text)
if(input == 0){ { } else(input == 1); }
You should have this:
Java Syntax (Toggle Plain Text)
if (input==0) { } else { }
Java Syntax (Toggle Plain Text)
if (input==0) { } else if (input==1) { } else { }
Check out my New Bike at my Public Profile at the "About Me" tab
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.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
•
•
Join Date: Oct 2008
Posts: 37
Reputation:
Solved Threads: 0
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.
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.
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.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
![]() |
Other Threads in the Java Forum
- Previous Thread: Clock.java
- Next Thread: Netbeans:Importing existing code conundrum...
| Thread Tools | Search this Thread |
account android api applet application array arrays automation bidirectional binary birt bluetooth class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse error errors exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield jtree julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source oracle plazmic print problem program project property recursion ria scanner search server set sharepoint smart sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree unlimited webservices windows






