dante cass

+ Follow
since Nov 02, 2009
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 dante cass

ok, so you can see from my above code that the return is wrong. I understand the clarifications by everyone on how the return shouldn't be in the for loop. To fix that I was thinking to create some sort of variable and as it loops through the forloop/array it concatinates the strings to a result that I can return at the end, outside of the forloop.

My result I am trying to achieve is this ; assertEquals("4x^3 + 3x^2 + 2x^1 + 1x^0", p1.toString());

The test case says I am returning this...4x^3.

Any ideas? Am I on the right track?
14 years ago
Thanks for the help.

Ok, what I am trying to do is to loop through the array and concatinate the results into a string as a decrements.

Maybe the best way would be to assign it to a variable and return that variable after the loop? Is that the right thinking?
14 years ago

Coefficients is an array from earlier in the program. I don't understand why this method isn't returning the return "" strings?
14 years ago
I changed the title for you, happy? obviously I misunderstood what he said.

I understand that you need to understand the assignment before writing the code. That goes for anything in life. I obviously thought I understood the assignment and didn't.

I appreciate your help but if your going to be snide about it then I'd rather you not respond at all. Good day.
14 years ago
Ok, so I am now lost. Do you think I should be finding the largest index? or the largest value at an index.

Also with the testing you suggested, I don't really know how to test it seeing I cant compile it because the program isn't finished.

If I am finding the largest index i with a non zero coefficient why would he want me to do a for loop? Why wouldn't I just use an if else statement with (coefficients.length-1)?

And isnt that why this code is doing?
14 years ago
What do you mean? I am looking for the largest value in the array and assigning it to "degree". How is it at odds?
14 years ago
Here is what I have so far.

My Prof. said this :
>> Your following code finds the index of the largest coefficient in the array.
>> It should find the largest index i with a non-zero coefficients[i] value.
>> You should change the logic to do that. (Start with degree = 0.)

i changed it to degree = 0 as you can see.
Is that all I had to change? My code is looping through the coefficients array and assigned "degree" to the largest value of the coefficients array index right?
Also, is the check of the non-zero coefficient correct? Thank you.
14 years ago
I solved it. I have to run to class. But just in case anyone was following, or for future googlers and people who helped. I will explain and post later. Thanks for your input guys, I have been reading through the site a bunch and can tell it will help greatly.
14 years ago
I believe it did. I am making progress btw. I have been able to print out the values of the rolls between 2 and 12.
I came up with this code

The result is this....
Value2: 20
Value3: 51
Value4: 73
Value5: 120
Value6: 141
Value7: 158
Value8: 137
Value9: 139
Value10: 77
Value11: 57
Value12: 27

Which is what I needed. Now I just need to figure out how to draw a scaled histogram of * before the value result. I know I have to use a nested for loop. but dont really know how...
14 years ago
Is this the correct way to find the max value?

Iterate over your values[] array and find the index of the largest value (maxValueIndex).

14 years ago
I edited this and hopefully this will work .
Basically I am trying to draw a histogram from the results of a dice roll. Two dice actually.
I have already written the code to determine the probabilities and now need to write a drawHor() method.

My teachers instructions were to :
1) limit size of histogram to maxLength
2) scale the data in the values array when we copy it into the instance copy of the data in the array.
Do # 2 using 2 loops. First loop find the largest values in the array "values".
Second loop multiplies each value in the values array by the max length we want for bars ( which is maxLength) and divides
by maxValue.

3)The drawHor() method needs to be in two nested loops. Outer will scan through each element of the array and the inner loop will
put an * from 1 through the value in the out loop element of the values array.
Print the values array integer at the end of each bar of asterisks.

That is my code so far. I stuck. I do not expect an answer or even code in the response. I just need to know what I should be looking at learning more about and where I am going wrong. Maybe a link or something. I have been on java tutorial for hours and reading my book. ( Along with "head first java"). Thank you so much for your time it is truly appreciated.

p.s. Sorry Rob Camick, I run dual monitors and one is wide screen. Hope this fixes it.
14 years ago