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 me how to convert it to "2d to 1d"

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    My Mood
    Cool
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post help me how to convert it to "2d to 1d"

    import java.io.*;
    public class Dionisio_RProgram2 {
    public static void print_array(int[][] numbers)
    {

    for (int i=1; i<numbers.length; i++) {
    System.out.print("" + i + " |");
    for (int a=1; a<numbers[i].length; a++)
    System.out.print("\t" + numbers[i][a]);
    System.out.println(); }

    }

    public static void main(String[] args) throws IOException {
    BufferedReader r =
    new BufferedReader (new InputStreamReader(System.in));

    String yesno="u";
    boolean isExit=false;

    do{

    String row, column;
    int Columns = 0;
    int Rows = 0;
    System.out.print("\n");
    System.out.print("ENTER A NUMBER : ");
    row= r.readLine();
    Rows= Integer.parseInt( row );


    int values[][] = new int[Rows+1][Rows+1];
    int [][] m = new int[Rows][];
    for (int i=0; i < Rows; i++)
    m[i] = new int[Rows];
    for (int i=0; i < values.length; i++)
    for (int a=0; a < values[i].length; a++)
    values[i][a] = i*a;
    System.out.print("\n");
    for (int i=0; i < values.length; i++){
    System.out.print(" " + i + " ");
    }
    System.out.println();
    for (int i=0; i < values.length; i++){
    System.out.print("" + "" + "---");
    }
    System.out.println();
    print_array(values);
    System.out.print("\n\n");

    System.out.println("Try again (press 1 if yes/press 2 if no)?");
    yesno = r.readLine();

    if(yesno.equalsIgnoreCase("1")) {
    isExit=false;
    } else if(yesno.equalsIgnoreCase("2")) {
    isExit=true;
    }

    }while(!isExit);
    System.out.print("Goodbye!");


    }
    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: help me how to convert it to "2d to 1d"

    Well, since this is marked as solved I take it that it is solved. But for the record, I recommend reading the following:
    http://www.javaprogrammingforums.com...-get-help.html

Similar Threads

  1. Replies: 7
    Last Post: August 13th, 2011, 01:22 AM
  2. Replies: 6
    Last Post: November 12th, 2010, 04:40 AM
  3. Java says:"Hello World". I say:"It works!"
    By Davidovic in forum Member Introductions
    Replies: 4
    Last Post: June 29th, 2010, 07:13 AM
  4. "java.lang.NoSuchMethodError: main" and "fatal exception occured."
    By joachim89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2010, 08:35 AM
  5. Convert from 'C' to "java" (switch)
    By chronoz13 in forum Loops & Control Statements
    Replies: 7
    Last Post: October 6th, 2009, 08:20 PM