Need help with max/min'ing multiply

Reply

Join Date: Oct 2008
Posts: 37
Reputation: IMtheBESTatJAVA has a little shameless behaviour in the past 
Solved Threads: 0
IMtheBESTatJAVA IMtheBESTatJAVA is offline Offline
Light Poster

Re: Need help with max/min'ing multiply

 
0
  #21
Dec 9th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 822
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: Need help with max/min'ing multiply

 
0
  #22
Dec 9th, 2008
Thats what I have been suggesting you since a long while ago.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 37
Reputation: IMtheBESTatJAVA has a little shameless behaviour in the past 
Solved Threads: 0
IMtheBESTatJAVA IMtheBESTatJAVA is offline Offline
Light Poster

Re: Need help with max/min'ing multiply

 
0
  #23
Dec 12th, 2008
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.

  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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,625
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 221
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: Need help with max/min'ing multiply

 
0
  #24
Dec 12th, 2008
I hope that you realize that this is wrong:
  1. if(input == 0){
  2. {
  3.  
  4. }
  5. else(input == 1);
  6.  
  7. }

You should have this:
  1. if (input==0) {
  2.  
  3. } else {
  4.  
  5. }
OR:
  1. if (input==0) {
  2.  
  3. } else if (input==1) {
  4.  
  5. } else {
  6.  
  7. }
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 822
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: Need help with max/min'ing multiply

 
0
  #25
Dec 12th, 2008
Originally Posted by IMtheBESTatJAVA View Post
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.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 37
Reputation: IMtheBESTatJAVA has a little shameless behaviour in the past 
Solved Threads: 0
IMtheBESTatJAVA IMtheBESTatJAVA is offline Offline
Light Poster

Re: Need help with max/min'ing multiply

 
-1
  #26
Dec 15th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 822
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: Need help with max/min'ing multiply

 
0
  #27
Dec 15th, 2008
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.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC