943,518 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2284
  • Java RSS
You are currently viewing page 3 of this multi-page discussion thread; Jump to the first page
Dec 9th, 2008
0

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.
Reputation Points: -1
Solved Threads: 0
Light Poster
IMtheBESTatJAVA is offline Offline
36 posts
since Oct 2008
Dec 9th, 2008
0

Re: Need help with max/min'ing multiply

Thats what I have been suggesting you since a long while ago.
Reputation Points: 485
Solved Threads: 89
Posting Shark
verruckt24 is offline Offline
944 posts
since Nov 2008
Dec 12th, 2008
0

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.

Java Syntax (Toggle Plain Text)
  1. public class Powers
  2. {
  3. public static void main(String[] args){
  4.  
  5. ConsoleIO console = new ConsoleIO();
  6. int input;
  7. int numOneTensLow = 10;
  8. int numTwoTensLow = 20;
  9. int numThreeTensLow = 30;
  10. int numOneOnesLow = 4;
  11. int numTwoOnesLow = 5;
  12. int numThreeOnesLow = 6;
  13. int numOneTensHigh = 90;
  14. int numTwoTensHigh = 80;
  15. int numThreeTensHigh = 70;
  16. int numOneOnesHigh = 6;
  17. int numTwoOnesHigh = 5;
  18. int numThreeOnesHigh = 4;
  19. int numOneLowOne = numOneTensLow + numOneOnesLow;
  20. int numTwoLowOne = numTwoTensLow + numTwoOnesLow;
  21. int numThreeLowOne = numThreeTensLow + numThreeOnesLow;
  22. int numOneHighOne = numOneTensHigh + numOneOnesHigh;
  23. int numTwoHighOne = numTwoTensHigh + numTwoOnesHigh;
  24. int numThreeHighOne = numThreeTensHigh + numThreeOnesHigh;
  25. int numOneLowTwo = numOneTensLow + numOneOnesLow;
  26. int numTwoLowTwo = numTwoTensLow + numThreeOnesLow;
  27. int numThreeLowTwo = numThreeTensLow + numTwoOnesLow;
  28. int numOneHighTwo = numOneTensHigh + numOneOnesHigh;
  29. int numTwoHighTwo = numTwoTensHigh + numThreeOnesHigh;
  30. int numThreeHighTwo = numThreeTensHigh + numTwoOnesHigh;
  31. int numOneLowThree = numOneTensLow + numTwoOnesLow;
  32. int numTwoLowThree = numTwoTensLow + numOneOnesLow;
  33. int numThreeLowThree = numThreeTensLow + numThreeOnesLow;
  34. int numOneHighThree = numOneTensHigh + numTwoOnesHigh;
  35. int numTwoHighThree = numTwoTensHigh + numOneOnesHigh;
  36. int numThreeHighThree = numThreeTensHigh + numThreeOnesHigh;
  37. int numOneLowFour = numOneTensLow + numTwoOnesLow;
  38. int numTwoLowFour = numTwoTensLow + numThreeOnesLow;
  39. int numThreeLowFour = numThreeTensLow + numOneOnesLow;
  40. int numOneHighFour = numOneTensHigh + numTwoOnesHigh;
  41. int numTwoHighFour = numTwoTensHigh + numThreeOnesHigh;
  42. int numThreeHighFour = numThreeTensHigh + numOneOnesHigh;
  43. int numOneLowFive = numOneTensLow + numThreeOnesLow;
  44. int numTwoLowFive = numTwoTensLow + numOneOnesLow;
  45. int numThreeLowFive = numThreeTensLow + numTwoOnesLow;
  46. int numOneHighFive = numOneTensHigh + numThreeOnesHigh;
  47. int numTwoHighFive = numTwoTensHigh + numOneOnesHigh;
  48. int numThreeHighFive = numThreeTensHigh + numTwoOnesHigh;
  49. int numOneLowSix = numOneTensLow + numThreeOnesLow;
  50. int numTwoLowSix = numTwoTensLow + numTwoOnesLow;
  51. int numThreeLowSix = numThreeTensLow + numOneOnesLow;
  52. int numOneHighSix = numOneTensHigh + numThreeOnesHigh;
  53. int numTwoHighSix = numTwoTensHigh + numTwoOnesHigh;
  54. int numThreeHighSix = numThreeTensHigh + numOneOnesHigh;
  55. int lowproductone = (numOneLowOne * numTwoLowOne * numThreeLowOne);
  56. int highproductone = (numOneHighOne * numTwoHighOne * numThreeHighOne);
  57. int lowproducttwo = (numOneLowTwo * numTwoLowTwo * numThreeLowTwo);
  58. int highproducttwo = (numOneHighTwo * numTwoHighTwo * numThreeHighTwo);
  59. int lowproductthree = (numOneLowThree * numTwoLowThree * numThreeLowThree);
  60. int highproductthree = (numOneHighThree * numTwoHighThree * numThreeHighThree);
  61. int lowproductfour = (numOneLowThree * numTwoLowThree * numThreeLowThree);
  62. int highproductfour = (numOneHighFour * numTwoHighFour * numThreeHighFour);
  63. int lowproductfive = (numOneLowFive * numTwoLowFive * numThreeLowFive);
  64. int highproductfive = (numOneHighFive * numTwoHighFive * numThreeHighFive);
  65. int lowproductsix = (numOneLowSix * numTwoLowSix * numThreeLowSix);
  66. int highproductsix = (numOneHighSix * numTwoHighSix * numThreeHighSix);
  67.  
  68. System.out.println("This program will calculate three two-digit" +
  69. " numbers that create the lowest and highest possible products " +
  70. "using the numbers 1 through 9 once in each.");
  71. System.out.println("To calculate the highest input 1, to calculate" +
  72. " the lowest, input 0: ");
  73. input = console.readInt();
  74.  
  75.  
  76.  
  77. if(input == 0){
  78. {
  79. System.out.println(lowproductone);
  80. System.out.println(lowproducttwo);
  81. System.out.println(lowproductthree);
  82. System.out.println(lowproductfour);
  83. System.out.println(lowproductfive);
  84. System.out.println(lowproductsix);
  85. }
  86. else(input == 1);
  87. System.out.println(highproductone);
  88. System.out.println(highproducttwo);
  89. System.out.println(highproductthree);
  90. System.out.println(highproductfour);
  91. System.out.println(highproductfive);
  92. System.out.println(highproductsix);
  93. }
  94.  
  95. }}}}

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.
Reputation Points: -1
Solved Threads: 0
Light Poster
IMtheBESTatJAVA is offline Offline
36 posts
since Oct 2008
Dec 12th, 2008
0

Re: Need help with max/min'ing multiply

I hope that you realize that this is wrong:
Java Syntax (Toggle Plain Text)
  1. if(input == 0){
  2. {
  3.  
  4. }
  5. else(input == 1);
  6.  
  7. }

You should have this:
Java Syntax (Toggle Plain Text)
  1. if (input==0) {
  2.  
  3. } else {
  4.  
  5. }
OR:
Java Syntax (Toggle Plain Text)
  1. if (input==0) {
  2.  
  3. } else if (input==1) {
  4.  
  5. } else {
  6.  
  7. }
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
javaAddict is offline Offline
3,258 posts
since Dec 2007
Dec 12th, 2008
0

Re: Need help with max/min'ing multiply

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.
Reputation Points: 485
Solved Threads: 89
Posting Shark
verruckt24 is offline Offline
944 posts
since Nov 2008
Dec 15th, 2008
-1

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.
Reputation Points: -1
Solved Threads: 0
Light Poster
IMtheBESTatJAVA is offline Offline
36 posts
since Oct 2008
Dec 15th, 2008
0

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.
Reputation Points: 485
Solved Threads: 89
Posting Shark
verruckt24 is offline Offline
944 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Clock.java
Next Thread in Java Forum Timeline: Netbeans:Importing existing code conundrum...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC