Array manipulation

15 pts.
Tags:
Array processing
Arrays
Arrays (programming)
Diagonal matrix
Java
Java Array
i want to create a 10x10 matrix(with user input) for e.g., i have given a small sample of 2x2 matrix and below is the description regarding what manipulation i want to do. say for e.g my matrix is 0.76   1 0      0.3 now what i want to do is that, whenever the value in the matrix is greater than 0.25, i want to print 1 and if it is less than 0.25 than i want to print 0 and if it is 0 or 1 then let it be as it is.... so the answer for my above matrix should be 1    1 0    0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Yashpal, that seems to be your homework. It is not a good idea to ask for the solution here. However, if you post your current code and ask for help on a specific problem/doubt, the community could offer some guidance.
    70,220 pointsBadges:
    report
  • Yashpal
    This is the code which i have written. Although i have given the elements here itself, as my immediate need is to manipulate the matrix... but can't get the required output. in fact, it shows me error. plz help. public class Matrix { public static void main(String args[]) { double val[][]={ {1, 0.76, 0.64, 0.11, 0.05, 0, 0, 0.12, 0.15, 0}, {0.76, 1, 0.32, 0, 0.67, 0.13, 0.23, 0.43, 0, 0.05}, {0.64, 0.32, 1, 0.13, 0.24, 0, 0, 0.15, 0, 0}, {0.11, 0, 0.13, 1, 0.54, 0.83, 0.57, 0, 0, 0}, {0.05, 0.67, 0.24, 0.54, 1, 0.2, 0.41, 0.2, 0.23, 0}, {0, 0.13, 0, 0.83, 0.2, 1, 0.69, 0.15, 0, 0}, {0, 0.23, 0, 0.57, 0.41, 0.69, 1, 0.18, 0, 0.12}, {0.12, 0.43, 0.15, 0, 0.2, 0.15, 0.18, 1, 0.84, 0.61}, {0.15, 0, 0, 0, 0.23, 0, 0, 0.84, 1, 0.65}, {0, 0.05, 0, 0, 0, 0, 0.12, 0.61, 0.65, 1} }; double th[][] = {{0.25,0.25}}; int i,j; for(i=0; i<val.length;i++) { int count = 1; for(j=0;j<val[i].length;j++) { if (val[i][j] < th[i][j]) System.out.println(count); } } } }
    15 pointsBadges:
    report
  • carlosdl
    is it a compile time or run time error ? What is the error message ? What is the line of code causing the error ?
    70,220 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following