Ashley Kin

Ranch Hand
+ Follow
since Oct 18, 2011
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ashley Kin

Hello, I'm trying to write a class Line that forms a line from two points. I have a separate Line main and Point class.
I'm getting errors saying that I need to have a return type for my LineAB method? I'm not sure why, as I mean for it to be a constructor. Do I have a logic error?
I have my other try in comments.
Any help is appreciated, thanks!

12 years ago

Mohamed Sanaulla wrote:You dont have i,j initialized.
You would want to take user input regarding the size of the arrays and then store them into some variables.

Also your matrixC isn't initialized and the method matrixAdd expects another argument and you are passing only two matrices whereas it requires 3.

May be you can try using Lists so that you dont have to worry about the size, but anyways you can manage with arrays also.

And I see that in your matrixAdd you are multiplying the elements?

Thanks for catching my mistakes, I edited my question with my new code.
Now I'm having some trouble initializing matrixC?
12 years ago
Hi, I'm trying to write a method that accepts accepts a pair of two dimensional arrays of integers as parameters (matrixA and matrixB)
and returns a new array as a sum (matrixC). The sum of matrixA and matrixB is matrixC, where for every row i and column j, C(ij) = A(ij) + B(ij).
I'm having trouble initializing matrixC. How do I set it up so I can edit each "element" of the matrix every time I add?
Thanks for any help!

12 years ago
When I replace i with 1, this is the output I get:

[[I@635b9e68, [I@13fcf0ce, [I@43256ea2, [I@4e82701e]

I'm not sure if this is an error or what?
12 years ago
I'm trying to print an array in the form of a 4 by 6 grid.
My for loop is getting the error: ArrayIndexOutOfBoundsException: 4
What does this mean and how do I go about fixing it?

12 years ago
Hi, I'm trying to print this tic-tac-toe board out using arrays and nested for loop.
The board has 3 rows and 3 columns.

This is what I have so far, and it's printing the same String of the array board three times with || between.
I've been stuck for a while and I'd appreciate any help, thanks!

12 years ago
Hi, I'm trying to print a 2-d array of powers, but I'm having trouble getting my head around the idea of columns and rows.
So if I'm correct, is my inner loop assigning values in the array for columns, and my outer for loop is for the rows?
Or should I have a separate array for each row of the table?
Thanks for any help!

is printing:

It should be printing:

[1.0 1.0 1.0 1.0 ]
[2.0 4.0 8.0 16.0 ]
[3.0 9.0 27.0 81.0 ]
[4.0 16.0 64.0 256.0 ]
[5.0 25.0 125.0 625.0 ]
[6.0 36.0 216.0 1296.0 ]
[7.0 49.0 343.0 2401.0 ]
[8.0 64.0 512.0 4096.0 ]
[9.0 81.0 729.0 6561.0 ]
[10.0 100.0 1000.0 10000.0 ]
12 years ago
Hi, I'm trying to make a 2-dimensional array of integers called grid with 4 rows and 6 columns.
I'm supposed to write a loop that initializes the second row to store integers starting with 2 and incrementing by 3 for each element in the row.
So the second row would have integers 2, 5, 8, 11, 14, 17.

This is what I have so far:
I'm not sure how to increment by 3 each time.
And am I referring to the right location in the array by saying grid[1][1]? Is that row 2, column1?
Thanks for any help!

also, I'd also appreciate help with ArrayIndexOutOfBoundsException. I think I'm going past the bounds of my array, but how can I avoid that when using a for loop?
12 years ago
Hi, I'm trying to use a for:each loop for the first time to write a method to find the number of even integers in an array.
My main calls:

and this is my method:

This prints 0.0 as the number of evens, which is not right.
Thanks for any help!
12 years ago
Yes, thank you, that worked very well!
12 years ago
For some reason, my program is skipping over the first prompt to the user to type in a word.
For examples, it simply goes like this:

Please type an adjective: Please type a plural noun:

Everything else works fine, it's just passing over the first line or something.
Any help is appreciated, thanks!

12 years ago
Oh wow, I see. Thanks for catching that! My full program works now!
12 years ago
I compile it and it runs without error, but nothing prints out and the run does not end. Is it because the string starts with a name?

This is my complete code right now:

12 years ago
I'm trying to write a method that accepts a string of names followed by integers, and the names alternate between boys and girls.
For examples: "Mark 41 Jennifer 22 Daniel 49 Jessica 67 Joshua 87"
The output should be:
3 boys, 2 girls
boys sum = 177
girls sum = 89

I'm having trouble just figuring out first of all how to alternate, and then how to get past the names to the integers.
Any help is appreciated, thank you!

12 years ago
Hi, I'm trying to use file line/token processing to read the number of lines and characters, and determine the longest line, then print the text of the longest line.

I have the number of lines down, but I'm having trouble with the other three things. Is there a nextChar() method, like the nextInt() one?
It is a static method that takes a Scanner representing a file as a parameter and then reports statistics about the file.

This is the portion of the main method that pertains to the method textCount:

And this is what I have so far:

Thank you for any help!
12 years ago