Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

J Calabrese

Greenhorn
+ Follow
since Jun 10, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by J Calabrese

1. I thought of that, and fixed it.

2. yes it is always 8

3. It was most definitely a typo. I have fixed your recommendations and this is what I have now:



edit: That worked, which is wonderful. Thanks so much for your help.

[ June 16, 2008: Message edited by: J Calabrese ]
[ June 16, 2008: Message edited by: J Calabrese ]
13 years ago
I edited some things I had done wrong in the main post.

And what do you mean bill? I don't think my variables are hurting anything, as I need to somehow get the sum of each row into a new array.
13 years ago
I am doing a project where I have to sum each row in a 2-dimensional array. The thing is that this must be done in a separate method, then returned to the main method as a new array. I know how to sum each row in a 2-dimensional array, but I don't know how to create a new array with this.

Here is what I have so far:



So I guess what I need help with is how to get the sum of each row into the new array sum[]. Any help?

[ June 16, 2008: Message edited by: J Calabrese ]

[ June 16, 2008: Message edited by: J Calabrese ]
[ June 16, 2008: Message edited by: J Calabrese ]
13 years ago
sorry guys, I changed it. I overlooked that when I was changing my profile and password.
13 years ago
I type casted Math.random() to make it int. Anyways, I got it to work using the switch statement. If anyone else needs help in the future, this is an example they can use:

13 years ago
We are just now learning arrays, so I don't feel comfortable with them yet.

But I thought of a way to do it.

Since there are 4 random comments possible, I can randomly generate an int number from 1-4. From there, I can use a switch statement to print out the random comment from the random number that was generated. Wouldn't that work?
13 years ago
I'm finishing up a project and I just can't get it done fully. We are generating two random numbers, then asking the user to input their guess on the product of the two numbers. If it is correct, it is supposed to show up a random "good" comment (which I have listed). There are 4 good comments. If the answer is wrong, it is supposed to show up a random "bad" comment, which I also have already. There are 3 bad comments.

I have everything correct in my program, but I don't know how to generate a random comment, or as I should say, string.

So let me give you an example:

The 2 random numbers would be 2 and 4.

The user inputs 8 as the answer.

So it is supposed to call the printGoodComment method and give back a random good comment from this list:

good job
excellent
terrific
nice work

So how would I go about randomizing those strings so each one is given randomly when an answer is correct?

EDIT: I've been given the hint to use Math.random() and switch, but I don't know where to start.
[ June 10, 2008: Message edited by: poopshakes ]
13 years ago