Results 1 to 2 of 2
  1. #1
    javagirl is offline Member
    Join Date
    Feb 2014
    Posts
    6
    Rep Power
    0

    Default Printing a variable using loops - algorithm

    I have 3 for loops here that do what I need them to do an individual basis. But, I can't seem to get them to work together. I need to calculate y=LN(E-k), compute the error and error squared value for y and print the variable when the value for y gives the lowest error squared value. Hope this makes sense.


    Java Code:
    	//Calculating y=LN(E-k) and Initializing the Array
    		for(int x=0; x<LNValues.length; x++)
    		{
    			//for(int y=0; y<9; y++)
    			//{
    				double i = Math.log(eValues[x][0] - kValue);
    				if(i > 0)
    				{
    					LNValues[x][0] = roundThreeDecimals(i);
    				}
    				else
    				{
    					LNValues[x][0] = 0;
    				}
    			//}
    		}
    
    	//Calculating Error Figures and Error Square
    
    		for(int x=0; x<errorValues.length; x++){
    			//for(int y=0; y<9; y++){
    				double j = LNValues[x][0] - eventSpecies[x][0];
    				if(j != 0.0){
    					errorValues[x][0] = roundThreeDecimals(j);
    					errorSquared[x][0] = roundThreeDecimals(Math.pow(j, 2));
    				}else{
    					errorValues[x][0] = 0;
    					errorSquared[x][0] = 0;
    				}
    
    			//}
    		}
    
    	//Print Error Squared Values
    
    		double errorSquareTotal = 0;
    		for(int x=0; x<errorSquared.length; x++){
    			//for(int y=0; y<9; y++){
    				errorSquareTotal += errorSquared[x][0];
    			//}
    		}

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,436
    Rep Power
    25

    Default Re: Printing a variable using loops - algorithm

    get them to work together
    Please explain what that means.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Variable Number of Nested For Loops
    By atomant in forum New To Java
    Replies: 5
    Last Post: 03-04-2012, 07:20 AM
  2. Replies: 0
    Last Post: 12-26-2011, 03:52 PM
  3. Replies: 20
    Last Post: 03-22-2011, 04:02 AM
  4. Printing Two Dimensional Arrays with for loops
    By mcnam4119 in forum JCreator
    Replies: 3
    Last Post: 10-06-2010, 05:27 AM
  5. Variable Management in Loops
    By rp181 in forum New To Java
    Replies: 2
    Last Post: 03-23-2010, 11:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •