Results 1 to 8 of 8

Thread: help in matrix

  1. #1
    Engineer is offline Member
    Join Date
    Aug 2010
    Location
    Egypt
    Posts
    34
    Rep Power
    0

    Default help in matrix

    Hello,
    please ,i need nessacry help
    i want make program of matrix
    that user can enter rows and coulmns in matrix
    i know that i must use two_dimantions array
    but how i make it ,i tried alot and failed...

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,508
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Engineer View Post
    but how i make it ,i tried alot and failed...
    Well, time to go back to the drawing board ... A matrix is a two dimensional block of numbers. Do you want the sizes of that block to be adjustable on the go or do you want to 'set up' a matrix with the sizes given at construction time? What do you want to do with those matrixes? Just the 'normal' mathematical operations or more fancy stuff? Do those matrixes contain a lot of zeros, i.e. are they 'sparse'? Are those matrixes square matrixes? Any other structure imposed on the numberds they contain? (i.e. symmetrical, (tri)diagonal etc.) Do they contain complex numbers or just doubles? Are they extremely large?

    kind regards,

    Jos

  3. #3
    Engineer is offline Member
    Join Date
    Aug 2010
    Location
    Egypt
    Posts
    34
    Rep Power
    0

    Default

    iam student in faculty of engineering.......
    there are some of lows in algebra very complex i want to solve it with java
    in my program i want the user enter the program and ask him to indicate the size of matrix
    example ::please enter the numbers of row
    3
    please enter the numbers of coulms
    2
    enter your matrix
    1 3
    8 9

    thats what i want ........:)

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,508
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Engineer View Post
    iam student in faculty of engineering.......
    there are some of lows in algebra very complex i want to solve it with java
    in my program i want the user enter the program and ask him to indicate the size of matrix
    example ::please enter the numbers of row
    3
    please enter the numbers of coulms
    2
    enter your matrix
    1 3
    8 9

    thats what i want ........:)
    Ok, you've shown us what you want, now show us what you've tried. b.t.w. your matrix example has two rows and two columns, bad example.

    kind regards,

    Jos

  5. #5
    Engineer is offline Member
    Join Date
    Aug 2010
    Location
    Egypt
    Posts
    34
    Rep Power
    0

    Default

    oh, iam sorry for this example
    enter your matrix
    1 3
    8 9
    5 6
    i want to know how can i make that
    how to make user enter his matrix but i cant
    Scanner num= new Scanner(System.in);
    System.out.print("Enter the number of your rows");
    int row=num.nextInt();
    System.out.print("Enter the number of your coulmns");
    int coulm=num.nextInt();
    int[][] mx = new int[row][coulm];
    for(int r=0;r<row; r++)
    for(int c=0;r<coulm; c++){
    double ro=num.nextDouble();
    mx [row][coulm]=(int) ro;


    System.out.print(mx [row][coulm]);

    }

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,508
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Engineer View Post
    oh, iam sorry for this example
    enter your matrix
    1 3
    8 9
    5 6
    i want to know how can i make that
    how to make user enter his matrix but i cant
    Scanner num= new Scanner(System.in);
    System.out.print("Enter the number of your rows");
    int row=num.nextInt();
    System.out.print("Enter the number of your coulmns");
    int coulm=num.nextInt();
    int[][] mx = new int[row][coulm];
    for(int r=0;r<row; r++)
    for(int c=0;r<coulm; c++){
    double ro=num.nextDouble();
    mx [row][coulm]=(int) ro;


    System.out.print(mx [row][coulm]);

    }
    Please use code tags when you're posting code. What do you think that last line does? hint: matrix mx only has row rows and 'coulm' colums so those values are not valid index values. You should print the value of the current mx[r][c] instead.

    Also: why are you reading 'double' values and cast them to ints? Why not just reads ints instead?

    kind regards,

    Jos

  7. #7
    Engineer is offline Member
    Join Date
    Aug 2010
    Location
    Egypt
    Posts
    34
    Rep Power
    0

    Default

    Scanner num= new Scanner(System.in);
    System.out.print("Enter the number of your rows");
    int row=num.nextInt();
    System.out.print("Enter the number of your coulmns");
    int coulm=num.nextInt();
    int[][] mx = new int[row][coulm];
    for(int r=1;r<row; r++){
    for(int c=1;r<coulm; c++){
    int ro=num.nextInt();
    mx [r][c]= ro;


    System.out.print(mx [r][c]);

    }
    }
    this my code but there are errors in it???????
    and didnt make what i want !!!!!!!!i tried
    sorry, all options that make me put code in php are stop !!!!!!!

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,508
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Engineer View Post
    Scanner num= new Scanner(System.in);
    System.out.print("Enter the number of your rows");
    int row=num.nextInt();
    System.out.print("Enter the number of your coulmns");
    int coulm=num.nextInt();
    int[][] mx = new int[row][coulm];
    for(int r=1;r<row; r++){
    for(int c=1;r<coulm; c++){
    int ro=num.nextInt();
    mx [r][c]= ro;


    System.out.print(mx [r][c]);

    }
    }
    this my code but there are errors in it???????
    Why didn't you put your code in [code] ... [/code] tags? Why don't you show us the errors you saw/read? Do you want us to guess? Do you think that's funny?

    kind regards,

    Jos

Similar Threads

  1. Help with dox matrix printer
    By Albert in forum Advanced Java
    Replies: 7
    Last Post: 09-06-2011, 08:50 AM
  2. matrix multiply
    By slixtrix in forum New To Java
    Replies: 8
    Last Post: 09-13-2010, 06:50 AM
  3. scalability of matrix
    By ajay kumar in forum New To Java
    Replies: 1
    Last Post: 12-07-2009, 08:21 AM
  4. Scalability of matrix
    By ajay kumar in forum New To Java
    Replies: 0
    Last Post: 12-04-2009, 05:19 AM
  5. Help with matrix
    By susan in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 04:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •