Hi,

I am getting the following errors:

HelloWorldApp.java:54: <identifier> expected
public static Vector<int[]> breakTheMovementVector(int i,int j){
^
HelloWorldApp.java:102: ';' expected
}
^
2 errors

import java.io.*;
import java.util.*;
class HelloWorldApp {
    public static void main(String[] args) {
        try{
    // Open the file that is the first 
    // command line parameter
	String fname=args[0];
	int x=0;
    FileInputStream fstream = new FileInputStream(fname);
    // Get the object of DataInputStream
    DataInputStream in = new DataInputStream(fstream);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine="",str1="";
    //Read File Line By Line
    while (x<2)   {
      // Print the content on the console
	  strLine = br.readLine();
	  x++;
	  if(x==1)str1=strLine;
	  if (x==2)
	  {
		  str1 = str1+" "+strLine;
	  }
	  // System.out.println (str1);
     
    }
    while ((strLine = br.readLine()) != null) 
	
			{

   System.out.println (strLine);
			}
	StringTokenizer st = new StringTokenizer(str1);
	st.nextToken();
    String width=st.nextToken();
	st.nextToken();
	String height = st.nextToken();
    //Close the input stream
	System.out.print ("width ");
	 System.out.println (width);
System.out.print ("height is  ");
	 System.out.println (height);
    in.close();
    }catch (Exception e){//Catch exception if any
      System.err.println("Error: " + e.getMessage());
    }


    }

	//BreaktheMovement Vector

public static Vector<int[]> breakTheMovementVector(int i,int j){
                               
							   Vector<int[]> result=new Vector<int[]>();
                                int signOfI;
                                int signOfJ;
                                double ii=new Double(Math.abs(i));
                                double jj=new Double(Math.abs(j));
                                if(i==0 && j==0)
                                return result;
                                if(i>0) signOfI=1; else signOfI=-1;
                                if(j>0) signOfJ=1; else signOfJ=-1;
											if (j==0){
											for (int f=0;f<ii;f++){
											int[] point={signOfI,0};
											result.add(point);
											}
                                            return result;
                                           }
										if (i==0){
										for (int f=0;f<jj;f++){
										int[] point={0,signOfJ};
										result.add(point);
										}
										return result;
										}
										Double a=1.0;
										Double b=1.0;
										double cross=((ii/jj)*(a-.5)+.5);
										while (b<=ii || a<=jj){
										if (b>cross){
										int[] point={0,signOfJ};
										result.add(point);
										a++;
										cross=((ii/jj)*(a-.5)+.5);
										}else if (b==cross){
										int[] point={signOfI,signOfJ};
										result.add(point);
										a++;
										b++;
										cross=((ii/jj)*(a-.5)+.5);
										}else if (b<cross){
										int[] point={signOfI,0};
										result.add(point);
										b++;
										}
										}
										return result;
												}
}

Sorry the code which I posted earlier was not properly indented.

import java.io.*;
import java.util.*;
class HelloWorldApp {
    public static void main(String[] args) {
        try{
    // Open the file that is the first 
    // command line parameter
	String fname=args[0];
	int x=0;
    FileInputStream fstream = new FileInputStream(fname);
    // Get the object of DataInputStream
    DataInputStream in = new DataInputStream(fstream);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine="",str1="";
    //Read File Line By Line
    while (x<2)   {
      // Print the content on the console
	  strLine = br.readLine();
	  x++;
	  if(x==1)str1=strLine;
	  if (x==2)
	  {
		  str1 = str1+" "+strLine;
	  }
	  // System.out.println (str1);
     
    }
    while ((strLine = br.readLine()) != null) 
	
			{

   System.out.println (strLine);
			}
	StringTokenizer st = new StringTokenizer(str1);
	st.nextToken();
    String width=st.nextToken();
	st.nextToken();
	String height = st.nextToken();
    //Close the input stream
	System.out.print ("width ");
	 System.out.println (width);
System.out.print ("height is  ");
	 System.out.println (height);
    in.close();
    }catch (Exception e){//Catch exception if any
      System.err.println("Error: " + e.getMessage());
    }


    }

	//BreaktheMovement Vector

public static Vector<int[]> breakTheMovementVector(int i,int j){
                               
	   Vector<int[]> result=new Vector<int[]>();
		int signOfI;
		int signOfJ;
		double ii=new Double(Math.abs(i));
		double jj=new Double(Math.abs(j));
		if(i==0 && j==0)
		return result;
		if(i>0) signOfI=1; else signOfI=-1;
		if(j>0) signOfJ=1; else signOfJ=-1;
					if (j==0){
					for (int f=0;f<ii;f++){
					int[] point={signOfI,0};
					result.add(point);
					}
					return result;
				   }
				if (i==0){
				for (int f=0;f<jj;f++){
				int[] point={0,signOfJ};
				result.add(point);
				}
				return result;
				}
				Double a=1.0;
				Double b=1.0;
				double cross=((ii/jj)*(a-.5)+.5);
				while (b<=ii || a<=jj){
				if (b>cross){
				int[] point={0,signOfJ};
				result.add(point);
				a++;
				cross=((ii/jj)*(a-.5)+.5);
				}else if (b==cross){
				int[] point={signOfI,signOfJ};
				result.add(point);
				a++;
				b++;
				cross=((ii/jj)*(a-.5)+.5);
				}else if (b<cross){
				int[] point={signOfI,0};
				result.add(point);
				b++;
				}
				}
				return result;
						}
}

Second version compiles without error for me.
Indentation is still useless - here's Eclipse's version.

class HelloWorldApp {

   public static void main(String[] args) {
      try {
         // Open the file that is the first 
         // command line parameter
         String fname = args[0];
         int x = 0;
         FileInputStream fstream = new FileInputStream(fname);
         // Get the object of DataInputStream
         DataInputStream in = new DataInputStream(fstream);
         BufferedReader br = new BufferedReader(new InputStreamReader(in));
         String strLine = "", str1 = "";
         //Read File Line By Line
         while (x < 2) {
            // Print the content on the console
            strLine = br.readLine();
            x++;
            if (x == 1) str1 = strLine;
            if (x == 2) {
               str1 = str1 + " " + strLine;
            }
            // System.out.println (str1);

         }
         while ((strLine = br.readLine()) != null)

         {

            System.out.println(strLine);
         }
         StringTokenizer st = new StringTokenizer(str1);
         st.nextToken();
         String width = st.nextToken();
         st.nextToken();
         String height = st.nextToken();
         //Close the input stream
         System.out.print("width ");
         System.out.println(width);
         System.out.print("height is  ");
         System.out.println(height);
         in.close();
      } catch (Exception e) {//Catch exception if any
         System.err.println("Error: " + e.getMessage());
      }

   }

   //BreaktheMovement Vector

   public static Vector<int[]> breakTheMovementVector(int i, int j) {

      Vector<int[]> result = new Vector<int[]>();
      int signOfI;
      int signOfJ;
      double ii = new Double(Math.abs(i));
      double jj = new Double(Math.abs(j));
      if (i == 0 && j == 0) return result;
      if (i > 0) signOfI = 1;
      else signOfI = -1;
      if (j > 0) signOfJ = 1;
      else signOfJ = -1;
      if (j == 0) {
         for (int f = 0; f < ii; f++) {
            int[] point = { signOfI, 0 };
            result.add(point);
         }
         return result;
      }
      if (i == 0) {
         for (int f = 0; f < jj; f++) {
            int[] point = { 0, signOfJ };
            result.add(point);
         }
         return result;
      }
      Double a = 1.0;
      Double b = 1.0;
      double cross = ((ii / jj) * (a - .5) + .5);
      while (b <= ii || a <= jj) {
         if (b > cross) {
            int[] point = { 0, signOfJ };
            result.add(point);
            a++;
            cross = ((ii / jj) * (a - .5) + .5);
         } else if (b == cross) {
            int[] point = { signOfI, signOfJ };
            result.add(point);
            a++;
            b++;
            cross = ((ii / jj) * (a - .5) + .5);
         } else if (b < cross) {
            int[] point = { signOfI, 0 };
            result.add(point);
            b++;
         }
      }
      return result;
   }
}

Stop posting your CSCI561 code to the internet. You are going to cause others to copy your code.

I don't know whether this is addressed to techie929 or to me, but either way your criticism is unfounded.

techie929 posted his code because he wanted help with compile errors. That's what we do here, we help people, and if he didn't post his code we couldn't help.

I took the code from his second post, ran it through Eclipse's source formatter and re-posted it so he could see that his idea of "properly indented" wasn't that good. I personally have no idea what CSCI561 is.

maybe so, perhaps I should have said "personally I neither know nor care care what CSCI561 is"!
I just had my feathers ruffled by a first-time anonymous poster criticising a perfectly normal and valid series of Daniweb posts. Time to move on...

Edited 5 Years Ago by JamesCherrill: n/a

that's true,

negative
... other hand, this forum has "more of democracy" as another forum where I meberber of, that very ... and counterproductive, topic by topic is very same, someone spllit out, hmmm then there is so difficult to choose if this post is about lazzynes, total ignore, soooo stopt and this people really need our hepl, maybe she/he want to learn more, yes, no or maybe its hard to decide, the result is superficiality

good/possitive ...but here isn't arrogance and personal attack

This article has been dead for over six months. Start a new discussion instead.