Results 1 to 6 of 6
  1. #1
    allan is offline Member
    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0

    Default help with my 2d arrays please

    i have 4 elements eachs containg 3 points and i want to check if each point is in range of 395 to 405 if not display that point with error message. im also if all 3 points on an element are under 400 i want do display an error aswell i think im very nearly there but i had to remover for loops to prevent continuos output can somone help please.

    Java Code:
    import SE112aClasses.*;
    
    
    public class Burger {
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		
    	
    
    
    
    		double[][] values = new double[3][4];
    		int[][] rounded = new int[3][4];
    		int tempi=0;
    		int tempx=0;
    		int i=0;
    		int x=0;
    		
    
    		GUI gui =new GUI();
    		
    		for(i=0;i<3;i++)
    		{
    			for( x=0;x<4;x++)
    			{
    				 
    				
    			values[i][x]=gui.getDouble("please enter temperature");
    			rounded[i][x]=(int)Math.round(values[i][x]);
    			
    			}
    			
    
    
    			
    		}
    		//for(int i=0;i<3;i++)
    		//{
    		//for(int x=0;x<4;x++)
    		//{
    			
    			tempi=i;
    			tempx=x;
    			if(rounded[i][x]<395 || rounded[i][x] >405)
    			{
    				System.out.println("there is an error with probe "+tempi+","+tempx+" :"+rounded[i][x]);
    				
    			}
    			
    		//}
    		//}
    
    		
    	//	 for(int i=0;i<3;i++)
    		//	{
    			//for(int x=0;x<4;x++)
    		//	{
    				
    				
    			
    			else if(values[x=0][i]< 400||values[x=1][i]<400||values[x=2][i]<400)
    				{
    					System.out.println("all points in element "+tempi+"as they are below 400 needs replaced("+"point "+tempx+" : "+values[i][x]+")");
    					
    				}
    				
    		//	}
    			//}
    
    			 
    		//System.out.println(values[0][0]);
    		//System.out.println(rounded[0][0]);
    		
    
    	}
    
    }

  2. #2
    allan is offline Member
    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0

    Default Re: help with my 2d arrays please

    Quote Originally Posted by allan View Post
    i have 4 elements eachs containg 3 points and i want to check if each point is in range of 395 to 405 if not display that point with error message. im also if all 3 points on an element are under 400 i want do display an error aswell i think im very nearly there but i had to remover for loops to prevent continuos output can somone help please.

    Java Code:
    import SE112aClasses.*;
    
    
    public class Burger {
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		
    	
    
    
    
    		double[][] values = new double[3][4];
    		int[][] rounded = new int[3][4];
    		int tempi=0;
    		int tempx=0;
    		int i=0;
    		int x=0;
    		
    
    		GUI gui =new GUI();
    		
    		for(i=0;i<3;i++)
    		{
    			for( x=0;x<4;x++)
    			{
    				 
    				
    			values[i][x]=gui.getDouble("please enter temperature");
    			rounded[i][x]=(int)Math.round(values[i][x]);
    			
    			}
    			
    
    
    			
    		}
    		//for(int i=0;i<3;i++)
    		//{
    		//for(int x=0;x<4;x++)
    		//{
    			
    			tempi=i;
    			tempx=x;
    			if(rounded[i][x]<395 || rounded[i][x] >405)
    			{
    				System.out.println("there is an error with probe "+tempi+","+tempx+" :"+rounded[i][x]);
    				
    			}
    			
    		//}
    		//}
    
    		
    	//	 for(int i=0;i<3;i++)
    		//	{
    			//for(int x=0;x<4;x++)
    		//	{
    				
    				
    			
    			else if(values[x=0][i]< 400||values[x=1][i]<400||values[x=2][i]<400)
    				{
    					System.out.println("all points in element "+tempi+"as they are below 400 needs replaced("+"point "+tempx+" : "+values[i][x]+")");
    					
    				}
    				
    		//	}
    			//}
    
    			 
    		//System.out.println(values[0][0]);
    		//System.out.println(rounded[0][0]);
    		
    
    	}
    
    }
    I have noted that noone has replieid have i put this in the wrong section ? just clarify i know how to store my 2d arrays im just looking for advice on how to obtain the required output

  3. #3
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    301
    Rep Power
    4

    Default Re: help with my 2d arrays please

    what is current status? how your code works now, what is the output and what is wrong with it?

  4. #4
    allan is offline Member
    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0

    Default Re: help with my 2d arrays please

    it reads in 12 different tempatures into all 12 points which are stored into 2d array set at [3][4] to the nearest whole number and checks to see if they are in range between 395 and 405
    then returns error mesage wtih coreect index and value of point that is out of range i think that works when that if is inside the second for loop which i have commented out just now the problem is the seconf test condition im trying to check if every point on an element wich holds 3 points is under 400 if true out put error with that element displayed also listing each point of that element . this one dosen't work correctly

  5. #5
    allan is offline Member
    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0

    Default Re: help with my 2d arrays please

    let me know you need more info im new to this form thanks

  6. #6
    allan is offline Member
    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0

    Default Re: help with my 2d arrays please

    it reads in 12 different tempatures into all 12 points which are stored into 2d array set at [3][4] to the nearest whole number and checks to see if they are in range between 395 and 405
    then returns error mesage wtih coreect index and value of point that is out of range i think that works when that if is inside the second for loop which i have commented out just now the problem is the seconf test condition im trying to check if every point on an element wich holds 3 points is under 400 if true out put error with that element displayed also listing each point of that element . this one dosen't work correctly

Similar Threads

  1. Copying Single Arrays to 2-D Arrays
    By jmscarlet9 in forum New To Java
    Replies: 7
    Last Post: 04-02-2012, 11:17 PM
  2. Casting Enum Type arrays to object type arrays
    By nmvictor in forum Advanced Java
    Replies: 4
    Last Post: 02-17-2012, 12:49 PM
  3. arrays and multidimensional arrays
    By belfast09 in forum New To Java
    Replies: 5
    Last Post: 06-14-2011, 01:28 PM
  4. store array of arrays in array of arrays
    By joost_m in forum New To Java
    Replies: 4
    Last Post: 04-19-2010, 10:32 AM
  5. Arrays.sort... why sorting all arrays in class?
    By innspiron in forum New To Java
    Replies: 6
    Last Post: 03-23-2010, 01:40 AM

Tags for this Thread

Posting Permissions

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