thomas_naveen 105 Junior Poster

Check whether you are closing the file after opening it.

In most cases you will need to open the file only once. (depends on your requirements)

Can you copy your code here?

thomas_naveen 105 Junior Poster

Make the following code change

public board()      {   
		setFocusable(true);
		addMouseListener(new Mouse());       
		addKeyListener(new Keyboard());

Remove the setFocusable(true) from the main.

thomas_naveen 105 Junior Poster

Please take a look at this thread.

thomas_naveen 105 Junior Poster

The code compiles if you make the below changes

JTextField T1,T2,T3,T4;
JPanel P1;
JPanel P2;
JPanel P3;
public BodyMass()
{
	P1=new JPanel();
	P2=new JPanel();
	P3=new JPanel();

Enclose your multiple statements after if and else in curly braces.

An example:

else if (n.equals("ORANGE"))
{
P1.setBackground(Color.ORANGE);
P2.setBackground(Color.ORANGE);
P3.setBackground(Color.ORANGE);
}

Please use code tags.

thomas_naveen 105 Junior Poster

Putting a break at the end of each case statement should work.

case 4:      
                  printf("Enter the bank's rating: ");      
                  scanf("%s",rating);             
                  printf("%s\n\n", rating);
                  break;
thomas_naveen 105 Junior Poster

The problem can be solved using only one array in the following manner.

I have also fixed a bug in remove where the sequence that I have given below in array was not getting converted properly.

public class arrayMod 
{

   /*
       I have statically populated the array. Leaving that part to you
   */
	
	public static String array[]={"0", "94", "12", "21", "3", "0", "0" ,"34" ,"26", "44" ,"55", "0", "32", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "56","0","0","67"};


	
	public static void main(String[] args)
	{		
		
                           compact();
	}
	public static void remove(int index) 
	{
		
		for(int i = index; i < array.length -1 ; i++) 
		{
			array[i] = array[i + 1];
		}	
		array[array.length-1] = "";
		
	} 
	public static void compact()
	{
		
		System.out.println(array);
		
		System.out.print("Before: ");
		for(int i = 0; i < array.length; i++)
		{
			System.out.print(array[i] + " ");
		}		
		
		System.out.println();
		for(int i = 0; i < array.length; i++)
		{
			int j = i;
			
			while(array[i] == "0")
			{	
				
				remove(i);
					
				
				if(j == array.length)
				{
					break;
				}
				
				j++;
				
			}	
		}
			
		
		System.out.println();
		System.out.print("After: ");
		for(int i = 0; i < array.length; i++) 
		{
			System.out.print(array[i] + " ");
		}
	}
		
		
	

}
thomas_naveen 105 Junior Poster

I haven't gone through either the problem or the solution. But I have a query. Why are you printing out the address of the returned variable. In printf on line 24, shouldn't you be printing out life_test instead of &life_test.

thomas_naveen 105 Junior Poster

Please refer to line 77. Looks like the two numbers are being printed together and appears like a single entity.

thomas_naveen 105 Junior Poster

Try removing the endl.

Otherwise copy the reversed string to a new string and print.

thomas_naveen 105 Junior Poster
for(count = SIZE; count >= 0; count--);

Remove the ';' at the end of the for. You are going to get some junk characters anyway since the size of the array is 11 and the string that you are passing is less than 11 characters.

To avoid this you could use some standard string length function to get the length of the string.

@hag++ Apologies. Didn't see your post.

thomas_naveen 105 Junior Poster

What was the input string?

thomas_naveen 105 Junior Poster

Can you copy the output of your program here?

thomas_naveen 105 Junior Poster

The only discrepancy that I can spot is that 'adder' is used in the if check (outside the function , in the first post) and 'adder1' is being passed to the function.

thomas_naveen 105 Junior Poster

Please give the entire code. There is nothing wrong with the code segment that you have pasted here.

thomas_naveen 105 Junior Poster

Unless you initialize i to 0 you will never compare seed_array[0] with the fruit array values.

thomas_naveen 105 Junior Poster

Can you give the actual command used to invoke the program?

for(int i=1;i<=count;i++)

Here , the first element in the seed array is getting ignored. This could be the reason that you are getting multiple entries of the same fruit in your result file.

thomas_naveen 105 Junior Poster

Please click here for more information.

thomas_naveen 105 Junior Poster

As Ancient Dragon has mentioned in his post, you should be using 'new' and 'delete' operators in C++.

malloc and free can be used in C.