Results 1 to 11 of 11
Like Tree2Likes
  • 2 Post By SurfMan

Thread: Two dimensional array question?

  1. #1
    tinker99 is offline Member
    Join Date
    Sep 2014
    Posts
    11
    Rep Power
    0

    Default Two dimensional array question?

    I am trying to create a program for class the uses two dimensional arrays. I am stuck on the second step that states Use two parallel arrays. One is a two-dimensional array -- a row of this array will hold six values in this order: [0] number of hours worked, [1] hourly pay rate, [2] gross pay, [3] net pay, [4] federal withholding, and [5] state withholding.

    This is what I have so far:
    Java Code:
    double [][] data = new double [30][6];
    String [] names = new String [30];
    String str = null;
    String detail = null;
    int n = input(data, names, inputFile);
    (there's more but i don't believe it pertains to this question)

    My question is how would I create this array. Or, is that right above? I've searched online and in my book and I just don't understand.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Two dimensional array question?

    That looks reasonable.
    Did you try putting the code in a source file and compiling it to see if there were any syntax errors?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    tinker99 is offline Member
    Join Date
    Sep 2014
    Posts
    11
    Rep Power
    0

    Default Re: Two dimensional array question?

    or would it be something like this?
    Java Code:
    int wages = 0, hours = 0, numofEmployees = 0;
    double grosspay = 0, withholdings = 0, netpay = 0, overtime;
    double [][] data = new double [30][7];
    String [] names = new String [30];
    String str = null;
    String detail = null;
    int n = input(data, names, inputFile); //n is name counter 25 total.

  4. #4
    tinker99 is offline Member
    Join Date
    Sep 2014
    Posts
    11
    Rep Power
    0

    Default Re: Two dimensional array question?

    Quote Originally Posted by Norm View Post
    That looks reasonable.
    Did you try putting the code in a source file and compiling it to see if there were any syntax errors?
    I have not yet. I just felt like I really didn't understand what I was doing during that step. I will finish more of the code and if I have a problem with that part I will post here again.

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Two dimensional array question?

    Compile it often to keep the number of error messages down and to localize where the errors are (they'll usually be in the last code that was added).
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    tinker99 is offline Member
    Join Date
    Sep 2014
    Posts
    11
    Rep Power
    0

    Default Re: Two dimensional array question?

    I am having an issue with it running. Here is what I have of the code:

    Java Code:
    import java.io.*;
    import java.text.*;
    import java.util.Scanner;
    import java.util.StringTokenizer;
    
    public class Employees_3_10 {
    
       static Toolkit tools = new Toolkit();
     
       public static void main (String[]args) throws Exception {
       
       Scanner input = new Scanner(System.in);
    
          // Define file names
          final String INPUT_FILE = "Employees_3_10_Input.txt";
          final String OUTPUT_FILE = "Employees_3_10_Output.txt";
    
          // Access the input/output files
          File inputDataFile = new File(INPUT_FILE);
           Scanner inputFile = new Scanner(inputDataFile);
           FileWriter outputDataFile = new FileWriter(OUTPUT_FILE);
           PrintWriter outputFile = new PrintWriter(outputDataFile);
          System.out.println("Reading file " + INPUT_FILE + "\r\n" +
                               "Creating file " + OUTPUT_FILE);
    
          // Define Variables
          int wages = 0, hours = 0, numofEmployees = 0;
          double grosspay = 0, Federalwithholdings = 0, Statewithholdings = 0, netpay = 0, overtime;
          double Statetaxrate = 0.045, Federaltaxrate = 0.18;
          double [][] data = new double [30][7];
          String [] names = new String [30];
          String str = null;
          String detail = null;
          int n = input(data, names, inputFile); //n is name counter 25 total.
    
       
          // Calculate Gross Pay
          if (hours < 40)
          {
          grosspay = hours*wages;
          }
          else if (hours >= 40)
          {
          grosspay = hours*wages + ((hours-40)*wages*1.5);
          }
          else if (hours > 50)
          {
          grosspay = hours*wages + ((50-40)*wages*1.5) + ((hours-50)*wages*2);
          }
    
    
    netpay = grosspay - Federalwithholdings - Statewithholdings;
    
    report(outputFile,names, n);
    
    outputFile.close();
    }
    //************************************************** ****************************************
    public static int input(double [][] data, String [] names, Scanner inputFile)
    {
    int i = 0;
    int m = 0;
    String line;
    StringTokenizer st;
    while (inputFile.hasNext() && i < names.length)
    {line = inputFile.nextLine();
    st = new StringTokenizer(line);
    m = st.countTokens();
    names [i] = st.nextToken();
    for (int j = 1; j < m-2; j++)
    names [i] = names [i] + " " + st.nextToken();
    data [i][5] = Double.parseDouble(st.nextToken());
    data [i][6] = Double.parseDouble(st.nextToken());
    i++;}
    return i;
    }	
    
    //*******************************************************************************************
     // Return the federal witholding
      public static double calcFed(double grosspay, double Federaltaxrate) { 
        return grosspay*Federaltaxrate;
      } // End calcFed
     
    //*******************************************************************************************
     // Return the State witholding
      public static double calcState(double grosspay, double Statetaxrate) {
       return grosspay*Statetaxrate;
      } //end calcState
    
    //*******************************************************************************************
       public static double roundNumber(double valueToRound, int placesToRound) {
    
          double roundMe;     // The number to round, starts as valueToRound
          double powerOfTen;  // To calculate 10^placesToRound 
          
          roundMe = valueToRound;                      // Ex: round 1.256, 2 places
          powerOfTen = Math.pow(10,placesToRound);     // 10 ^ 2 = 100
          roundMe = roundMe * powerOfTen;              // 1.256 * 100 = 125.6
          roundMe = Math.round(roundMe);               // 125.6 rounded = 126
          
          return roundMe / powerOfTen;                 // 126 / 100 = 1.26
       } // End roundNumber
    
    
    //************************************************** ****************************************
    public static String report(PrintWriter outputFile, String[]names, int n)
    {
    //outFile.println(heading());
    //outFile.println(summary(n));
    detail(outputFile,names, n);
    outputFile.println("\f");
    return null; 
    }
    
    //************************************************** ****************************************        
    public static String heading()
    {
    return " NATURAL PINE FURNITURE COMPANY" +
    "\n PAYROLL REPORT" +
    "\n-----------------------------------------------------------------------" +
    "---------------------" +
    "\nNAME" + " " + "NET PAY" + " " + "GROSS PAY" + " " + 
    "FEDERAL TAX" + " " + "STATE TAX" + " " +  
    "HOURS" + " " + "PAY RATE" +
    "\n-----------------------------------------------------------------------"
    + "---------------------";
    }
    //************************************************** ****************************************
    public static void detail(PrintWriter outputFile, String [] names, int n)
    {
    for (int i = 0; i < n; i++)
    outputFile.println(names[i]);
    }
    //************************************************** ****************************************
    public static void summary(PrintWriter outputFile, double netpay, double grosspay, int n,
                                     double Federalwithholdings, double Statewithholdings, double hours)
     {
      outputFile.println(" The total amount of netpay received for all employees is " 
                         + netpay + ".");
      outputFile.println(" The total amount of grosspay recieved for all employees is " + grosspay + ".");
      outputFile.println(" The total amount of federal withholdings for all employees is " 
                         + Federalwithholdings + ".");
      outputFile.println(" The total amount of state withholdings for all employees is "
                         + Statewithholdings + ".");
      outputFile.println(" The total amount of hours worked for all employees is " + hours + ".");                   
      outputFile.println(" The total amount of names processed is " + n + ".");
      outputFile.close();
     } // End summary
    
    }
    This is what I get when running it.
    Java Code:
    Reading file Employees_3_10_Input.txt
    Creating file Employees_3_10_Output.txt
    Exception in thread "main" java.lang.NumberFormatException: For input string: "Hancock"
    	at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
    	at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    	at java.lang.Double.parseDouble(Double.java:538)
    	at Employees_3_10.input(Employees_3_10.java:78)
    	at Employees_3_10.main(Employees_3_10.java:34)
    Here is the input file:
    41.00 11.74 Hancock John
    50.00 10.60 Light Karen L
    52.00 10.80 Fagan Bert Todd
    62.00 12.24 Antrim Forrest N
    38.40 14.74 Camden Warren
    44.33 12.04 Mulicka Al B
    41.75 13.40 Lee Phoebe
    24.00 11.40 Bright Harry
    41.00 10.40 Garris Ted
    43.00 12.00 Benson Martyne
    31.90 12.40 Lloyd Jeanine D
    44.00 13.50 Leslie Bennie A
    48.40 14.40 Brandt Leslie
    42.00 12.90 Schulman David
    50.10 10.84 Worthington Dan
    70.40 12.66 Hall Gus W
    40.10 12.74 Prigeon Dale R
    43.00 12.44 Fitzgibbons Rusty
    50.00 12.24 Feistner Merle S
    23.00 12.34 Hallquist Dottie
    43.33 10.90 Bolton Seth
    43.00 12.20 Taylor Gregg
    42.00 12.94 Raskin Rose
    50.10 12.44 Kenwood Pat
    44.33 14.64 Slaughter Lew

    I'm assuming it has something to do with that? I'm not sure how to fix this problem.

  7. #7
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,717
    Rep Power
    17

    Default Re: Two dimensional array question?

    Java Code:
    Reading file Employees_3_10_Input.txt
    Creating file Employees_3_10_Output.txt
    Exception in thread "main" java.lang.NumberFormatException: For input string: "Hancock"
        at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
        at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
        at java.lang.Double.parseDouble(Double.java:538)
        at Employees_3_10.input(Employees_3_10.java:78)
        at Employees_3_10.main(Employees_3_10.java:34)
    You read those stack traces from the top down until you come to a line of your code. In this case it's line 78 which is somewhere in the input() method. (When posting runtime errors it's a very good idea to say which line 78 is because it's not so easy for the rest of us to see that). That's the line that caused the problem.

    The line of the stack trace just above that gives a hint about what went wrong. Evidently the Double.parseDouble() method did not like the string you sent it to parse. Hence the "NumberFormatException" which is the exception you get when you try and parse a string as a double and the string is not, in fact, a numeral.

    To get a clearer idea of what is going on print the values of each string as you get it as a token from the line and indicate you are about to add it to the name or parse it with Double.parseDouble(). You read the data in the same order it's presented in the data file.

    ---

    It would be a good idea to tidy up the formatting of that method so that it's readable. For loops and firemen use braces to avoid embarrassment.

  8. #8
    tinker99 is offline Member
    Join Date
    Sep 2014
    Posts
    11
    Rep Power
    0

    Default Re: Two dimensional array question?

    Here is my finished code:
    Java Code:
    import java.io.*;
    import java.text.*;
    import java.util.Scanner;
    import java.util.StringTokenizer;
    
    public class Employees_3_10 {
        
        final static double FEDTAX = .18;
        final static double STTAX = .045;
    
       static Toolkit tools = new Toolkit();
     
       public static void main (String[]args) throws Exception {
       
       Scanner input = new Scanner(System.in);
    
          // Define file names
          final String INPUT_FILE = "Employees_3_10_Input.txt";
          final String OUTPUT_FILE = "Employees_3_10_Output.txt";
    
          // Access the input/output files
            Scanner InputFile = new Scanner(new FileReader (INPUT_FILE));
            Scanner InputFileCount = new Scanner(new FileReader (INPUT_FILE));
            PrintWriter OutputFile = new PrintWriter(OUTPUT_FILE);
            int lines = countLines(InputFileCount);
            InputFileCount.close();
     
    
    
          // Define Variables
          
          double [][] data = new double [30][7];
          String [] names = new String [30];
          names = new String[lines];
          data = new double[lines][2];
            
    
    
            input(data, names, InputFile);
            printHeading(OutputFile);
            printEmployeeLines(names, data, OutputFile);
            printSummary(names, data, OutputFile);
     
            sortNamesAlpha(names, data);
            printHeading(OutputFile);
            printEmployeeLines(names, data, OutputFile);
            printSummary(names, data, OutputFile);
     
            sortGrossPay(names, data);
            printHeading(OutputFile);
            printEmployeeLines(names, data, OutputFile);
            printSummary(names, data, OutputFile);
     
            OutputFile.close();
    }
    
    
    //************************************************** ****************************************
    public static int input(double [][] data, String [] names, Scanner inputFile)
    {
    int i = 0;
    int m = 0;
    String line;
    StringTokenizer st;
    while (inputFile.hasNext() && i < names.length)
    {
    line = inputFile.nextLine();
    st = new StringTokenizer(line);
    m = st.countTokens();
    names [i] = st.nextToken();
    for (int j = 1; j < m-2; j++)
    names [i] = names [i] + " " + st.nextToken();
    data [i][5] = Double.parseDouble(st.nextToken());
    data [i][6] = Double.parseDouble(st.nextToken());
    i++;}
    return i;
    }	
    
    //*******************************************************************************************
     public static void getName(String[] names, int i, StringTokenizer st){
            int m = st.countTokens();
                names[i] = st.nextToken();
                for (int j = 1; j < m - 2; j++){
                names[i] = names[i] + " " + st.nextToken();
                }
     }               
     //*******************************************************************************************
         public static int countLines(Scanner InputFile){
            String tmp;
            int i = 0;
            while (InputFile.hasNext()){
                tmp = InputFile.nextLine();
                i++;
            }// end while
            return i;
        }
    
    //*******************************************************************************************
       public static double roundNumber(double valueToRound, int placesToRound) {
    
          double roundMe;     // The number to round, starts as valueToRound
          double powerOfTen;  // To calculate 10^placesToRound 
          
          roundMe = valueToRound;                      // Ex: round 1.256, 2 places
          powerOfTen = Math.pow(10,placesToRound);     // 10 ^ 2 = 100
          roundMe = roundMe * powerOfTen;              // 1.256 * 100 = 125.6
          roundMe = Math.round(roundMe);               // 125.6 rounded = 126
          
          return roundMe / powerOfTen;                 // 126 / 100 = 1.26
       } // End roundNumber
    
    //******************************************************************************************
        public static void printHeading(PrintWriter OutputFile){
            int widthR = 17;
            int widthL = 12;
            OutputFile.println("|---------------------------------------------------" +
                    "------------------------------------------|");
            OutputFile.print(rightPadName("Name", widthR));
            OutputFile.print(leftPad("Net Pay", widthL));
            OutputFile.print(leftPad("Gross Pay", widthL));
            OutputFile.print(leftPad("Federal Tax", widthL));
            OutputFile.print(leftPad("State Tax", widthL));
            OutputFile.print(leftPad("Hours", 8));
            OutputFile.print(leftPad("Pay Rate|", 13));
            OutputFile.print("\n");
            OutputFile.println("|---------------------------------------------------" +
                    "------------------------------------------|");
        }// end print Heading
    //************************************************** ****************************************        
        public static void printEmployeeLines(String[] names, double[][] data, PrintWriter OutputFile){
        //name, net pay, gross pay, fed tax, state tax, dues, hours, pay rate
            for (int i=0; i< names.length; i++){
                int widthR = 17;
                int widthL = 12;
                String name = names[i];
                OutputFile.print(rightPadName(name, widthR));
                OutputFile.print(leftPadCurrency(calcNetPay(data, i), widthL));
                OutputFile.print(leftPadCurrency(calcGrossPay(data, i), widthL));
                OutputFile.print(leftPadCurrency(calcFedTax(data, i), widthL));
                OutputFile.print(leftPadCurrency(calcStTax(data, i), widthL));
                OutputFile.print(leftPad(data[i][0], 8));
                OutputFile.print(leftPadCurrency(data[i][1], widthL));
                OutputFile.print("|\n");
            }// end for
     }
    //************************************************** ****************************************
        public static double calcNetPay(double[][] data, int i){
            return (calcGrossPay(data, i) - calcFedTax(data, i) -
                    calcStTax(data, i));
        }// end clac net pay
    
    //*******************************************************************************************
    public static double calcGrossPay(double[][] data, int i){
            if (data[i][0] <= 40.0){
                return (data[i][0] * data[i][1]);
            }
            else if (data[i][0] < 50){
                return (((data[i][0] - 40) * 1.5 * data[i][1]) + data[i][1]*40);
            }
            else if (data[i][0] >= 50){
                return (((data[i][0] - 50) * 2 * data[i][1]) + data[i][1] * 40 +
                        15 * data[i][1]);
            }
            else{
                return 0;
            }
        }// end calc GrossPay
    
    //************************************************** ****************************************
    public static double calcFedTax(double[][] data, int i){
            return (calcGrossPay(data, i) * FEDTAX);
        }// End calcFedTax
        public static double calcStTax(double[][] data, int i){
            return (calcGrossPay(data, i) * STTAX);
        }// end calcStTax
     
        public static void sortNamesAlpha(String[] names, double[][] data){
            for(int i = 0; i < names.length; i++){
                for (int j = 0; j < data.length; j++){
                    if(names[i].compareTo(names[j]) > 0){
                        swapValues(data, i, j);
                        swapNames(names, i, j);
                    }//end if
                }// end for j
            }// end for i
        }// end sortNamesAlpha
    //*******************************************************************************************
        public static void sortGrossPay(String[] names, double[][] data){
            for(int i = 0; i < data.length; i++) {
                for(int j = i; j < data.length; j++) {
                    if(calcGrossPay(data, i) > calcGrossPay(data, j)){
                        swapValues(data, i, j);
                        swapNames(names, i, j);
                    }// end if
                }// end for
            }// end for
        }// end sortGrossPay
    //******************************************************************************************
        public static void swapValues(double[][] data, int i, int j) {
            double temp = data[i][0];
            data[i][0] = data[j][0];
            data[j][0] = temp;
            double temp2 = data[i][1];
            data[i][1] = data[j][1];
            data[j][1] = temp2;
        }// end swapValues
    //******************************************************************************************
        public static void swapNames(String[] names, int i, int j) {
            String temp = names[i];
            names[i] = names[j];
            names[j] = temp;
        }// end swap names
    //******************************************************************************************
        public static void printSummary(String[] names, double[][] data, PrintWriter OutputFile){
            int widthR = 17;
            int widthL = 12;
            OutputFile.println("|-----------------------------------------------------"+
                    "----------------------------------------|");
            OutputFile.print(rightPadName("Total", widthR));
            OutputFile.print(leftPadCurrency(calcTotalNetPay(data), widthL));
            OutputFile.print(leftPadCurrency(calcTotalGrossPay(data), widthL));
            OutputFile.print(leftPadCurrency(calcTotalFedTax(data), widthL));
            OutputFile.print(leftPadCurrency(calcTotalStTax(data), widthL));
            OutputFile.print(leftPad(calcTotalHours(data), 8));
            OutputFile.print("            |\n");
            OutputFile.println("|-----------------------------------------------------"+
                    "----------------------------------------|");
        }// end print summary
    //********************************************************************************************
    public static double calcTotalNetPay(double[][] data){
            double temp = 0;
            for(int i = 0; i < data.length; i++){
                temp += calcNetPay(data, i);
            }
            return temp;
        }// end calc total net pay
    //********************************************************************************************
        public static double calcTotalGrossPay(double[][] data){
            double temp = 0;
            for( int i = 0; i < data.length; i++){
                temp += calcGrossPay(data, i);
            }
            return temp;
        }// end calc total gross pay
    //*********************************************************************************************
        public static double calcTotalHours(double[][] data){
            double temp = 0;
            for(int i = 0; i< data.length; i++){
                temp += data[i][0];
            }
            return temp;
        }// end calc total hours
    //*********************************************************************************************
        public static double calcTotalFedTax(double[][] data){
            double temp = 0;
            for( int i = 0; i < data.length; i++){
                temp += calcFedTax(data, i);
            }
            return temp;
        }// end calc total fed tax
    //**********************************************************************************************
        public static double calcTotalStTax(double[][] data){
            double temp = 0;
            for( int i = 0; i < data.length; i++){
                temp += calcStTax(data, i);
            }
            return temp;
        }// end calc total st tax
    //**********************************************************************************************
        public static String leftPadCurrency(double num, int width){
            DecimalFormat fmt = new DecimalFormat("#,##0.00");
            String s = fmt.format(num);
            int m = s.length();
            for(int i=0; i < width - m; i++){
                if(m == 5 && i == 3 || m == 4 && i == 4 || m == 8 && i == 0){
                    s = "$" + s;
                }
                else if (m == 6 && i == 2)
                    s = "$" + s;
                else{
                    s = " " + s;
                }
            }
            return s;
     
        } // end leftPadCurrency
    //**********************************************************************************************
        public static String leftPadDues(double num, int width){
            DecimalFormat fmt = new DecimalFormat("#,##0.00");
            String s = fmt.format(num);
            int m = s.length();
            for(int i=0; i < width - m; i++){
                if(m == 4 && i == 2 || m == 6 && i == 0){
                    s = "$" + s;
                }
                else{
                    s = " " + s;
                }
     
            }
            return s;
        }
        // left pad takes numbers
    //***********************************************************************************************
        public static String leftPad(double num, int width){
            DecimalFormat fmt = new DecimalFormat("#,##0.0");
            String s = fmt.format(num);
            int m = s.length();
            for(int i=0; i < width - m; i++){
                    s = " " + s;
            }
            return s;
     
        } // end leftPad
    //***********************************************************************************************
        // overloaded leftPad takes string
        public static String leftPad(String s, int width){
            int m = s.length();
            for(int i=0; i < width - m; i++){
                    s = " " + s;
            }
            return s;
        } // end leftPad overloaded
    //***********************************************************************************************
        public static String rightPadName(String s, int width){
            int m = s.length();
            for(int i=0; i < width - m; i++){
                s = s + " ";
            }
            s = "|" + s;
            return s;
        }// end rightPadName
    }
    I am having the same problem with it though.

    Java Code:
    Exception in thread "main" java.lang.NumberFormatException: For input string: "Hancock"
    	at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
    	at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    	at java.lang.Double.parseDouble(Double.java:538)
    	at Employees_3_10.input(Employees_3_10.java:73)
    	at Employees_3_10.main(Employees_3_10.java:39)
    So the problem would be at line 73?
    Which is
    data [i][5] = Double.parseDouble(st.nextToken());

    I'm not really sure how to fix this line.

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Two dimensional array question?

    NumberFormatException: For input string: "Hancock"
    The problem is that the data being read in Not a double. The error message says that the String: "Hancock" was passed to the nextDouble() method which throws the exception.
    The code needs to handle "Hancock" as a String not as a number.

    Did you read post#7 about doing some debugging by printing what was read so you can see where the problem is?
    Last edited by Norm; 12-08-2014 at 12:28 PM.
    If you don't understand my response, don't ignore it, ask a question.

  10. #10
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Two dimensional array question?

    Its hard to follow code, but it doesn't seem to hard to spot where it goes wrong. The format of a line in the file is

    NUMBER NUMBER LASTNAME FIRSTNAME

    Yet the code does this:

    Java Code:
    for (int j = 1; j < m-2; j++)
    names [i] = names [i] + " " + st.nextToken();        // NUMBER
    data [i][5] = Double.parseDouble(st.nextToken()); // NUMBER
    data [i][6] = Double.parseDouble(st.nextToken()); // LASTNAME ... being parsed as a double? Eh?
    Can you understand yourself at this point what all the magic numbers and single character variables are? In other words: can you look at the code and explain what a specific line in it is doing? I certainly cannot. What is "i"? What is "m" ? Why [i][5] and [i][6], what do that 5 and 6 represent?

    Magic number (programming) - Wikipedia, the free encyclopedia

    Its very important to take a little more time to write readable code. It not only makes it easier to ask for help, it also makes it easier for yourself to keep a grip on the code you not only write but will re-write several times.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  11. #11
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,991
    Rep Power
    8

    Default Re: Two dimensional array question?

    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Code for readability.
    Martin Golding or John F. Woods (That's still open for discussion)
    gimbal2 and JosAH like this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Similar Threads

  1. [SOLVED] Three-Dimensional Array
    By Liq in forum New To Java
    Replies: 7
    Last Post: 07-04-2013, 06:11 PM
  2. two dimensional array
    By grace425 in forum New To Java
    Replies: 2
    Last Post: 02-23-2013, 12:01 AM
  3. Two dimensional Array
    By Juukamen in forum New To Java
    Replies: 4
    Last Post: 11-09-2011, 11:10 AM
  4. 2 dimensional array help!
    By ber1023 in forum New To Java
    Replies: 9
    Last Post: 01-02-2011, 12:29 AM
  5. two-dimensional array
    By kHim in forum New To Java
    Replies: 4
    Last Post: 11-16-2008, 07:21 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
  •