thomas_naveen 105 Junior Poster

Look at my edited post. Make that change and the following changes as well.

several issues that I failed to spot at first are:

public void setItemTotal(int total);

No semicolon is needed at the end of this line.

Same problem exists at other places as well.

private double totalInventory;

is not being used anywhere in the program.

Also , please use code tags when you post


[EDIT]

One thing more is that you should not be using two 'Cars' classes. Change one to CarDriver or something.

The two classes should be in two files and the file name should correspond to the class name.

Better still use a package for both these classes.

thomas_naveen 105 Junior Poster

try

itemTotal = total;
itemPrice = price;

instead of

setItemTotal = total of cars;
setItemPrice = price per car;
thomas_naveen 105 Junior Poster

If you reach to this level of granularity then there is not much to do , is there?

Once you get the string starting with SRC, you can copy the required part of it to another string using a loop (your exit criteria would be the occurrance of the D of DST) or some standard copy function.

[EDIT]

char src[20];

int i = 0;

while(1)
{

          if((src[i] == 'D') || (i >19))
          {
                        break;
           }
           src[i] = result[i];
           i++;


}
thomas_naveen 105 Junior Poster

In the while loop that you are using for printing why don't you do an strstr and extract the value that you need?

Something like

strstr(result, "SRC=");
thomas_naveen 105 Junior Poster

Have you tried using sprintf to print the hex formatted numbers onto a string.

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

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

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

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

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.