Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help with Arrays

  1. #1
    Member
    Join Date
    Sep 2012
    Posts
    31
    My Mood
    Confused
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Help with Arrays

    Hi I am trying to pass information from one method in to a 2 dimensional array any help is appreciated.
     
    import java.io.PrintStream;
    import java.util.Scanner;
     
    public class Survey {
     
        // instance variables
        public static final int SIZE = 10;
        private String title;
        private static int respondentID = 0;
        private static String[] questionsArray = new String[SIZE];
        private int numResponses;
     
        private boolean grid[][] = new boolean[SIZE][SIZE]; 
        private Scanner in = new Scanner(System.in);
     
        //Constructors
        // Default Constructor
        Survey() {
            setTitle("Customer Survey");
            generateRespondentId();
        }
     
        // Overloaded Constructor 1
        Survey(String ititle) {
            setTitle(ititle);
            setRespondentID(0);
        }
     
        public static int getRespondnetID() {
            return respondentID;
        }
     
        public static void setRespondentID(int respondentID) {
            Survey.respondentID = respondentID; // refers to respondentID in the first constructor
        }
     
        public String getITitle() {
            return title;
        }
     
        public void setTitle(String title) {
            this.title = title;
        }
     
        public static int getRespondentID(){
            return respondentID;
        }
     
        public static int generateRespondentId() {
            respondentID = 0;
            return ++respondentID;
        }
     
        public void enterQuestions() {
     
            for (int i = 0; i < questionsArray.length; i++) {
                System.out.print("Please enter question: ");    ///LOOK
                String question = in.nextLine();
                questionsArray[i] = question;
            }
     
            System.out.println();
        }
     
        public void displaySurveyResults(final boolean[][] grid, final int row, final int col) {
     
            System.out.printf(title, "\n");
     
            ///LOOK This method must display the contents of the 'grid' array. NOT the questions
            boolean[][] logResponse = new boolean[SIZE][SIZE];
            logResponse = grid;
            for (int row =1; row = < 10; row++){
            for(int col = 1; col < 10; col++){
                int q = gNumber(logResponse, row, col);            
            }
        }
        }
     
        public void logResponse() {
            int respondnetID;
            int response;
            int gNumber;
     
     
     
            respondnetID = new generateRespondentID();
            response = logResponse(response);
     
     
            } 
     
     
     
     
            ///LOOK logResponse MUST NOT do ANY input
     
        }
     
        public void displayQuestionStats() {
     
     
     
     
        }
     
    }


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Help with Arrays

    Do you have a question?

Similar Threads

  1. Arrays
    By LeeDD in forum What's Wrong With My Code?
    Replies: 12
    Last Post: March 9th, 2013, 09:09 PM
  2. Need help with arrays
    By Burnett98 in forum What's Wrong With My Code?
    Replies: 27
    Last Post: January 23rd, 2013, 05:23 PM
  3. 2d arrays
    By jonathanfox in forum Java Theory & Questions
    Replies: 5
    Last Post: August 7th, 2012, 10:02 AM
  4. Need Help with Arrays
    By zennbang in forum Object Oriented Programming
    Replies: 3
    Last Post: July 31st, 2011, 07:41 AM
  5. Arrays
    By av8 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 25th, 2011, 02:21 PM