Tammy Kline

+ Follow
since Apr 07, 2007
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 Tammy Kline

This is what it's supposed to look like (but with stars):

[Campbell@dhcppc0 disk]$ javac Stars.java
[Campbell@dhcppc0 disk]$ java Stars

In loop: x = 1, numberOfStars = 0 , *
In loop: x = 2, numberOfStars = 1 , *
In loop: x = 3, numberOfStars = 2 , *
In loop: x = 4, numberOfStars = 3 , *
In loop: x = 5, numberOfStars = 6 , *
In loop: x = 6, numberOfStars = 10 , *
In loop: x = 7, numberOfStars = 18 , *
In loop: x = 8, numberOfStars = 32 , *
In loop: x = 9, numberOfStars = 60 , *
In loop: x = 10, numberOfStars = 113 , *
[Campbell@dhcppc0 disk]$

I was getting that as well. That's what I'm supposed to get except instead of the words, just the numbers 1-10 and the numberofStars being actual stars instead of numbers!

I'm going to have to work more on this one later ... I'd definitely like to figure out exactly what I'm missing but right now I gotta move on to my next program. This class is quickly coming to a close (May 5 is my exam) and I've still got one more program to write <phew> ... this is a tough class!!

anyway, again, thank you for you help with this program ... if I figure out what my last bit is supposed to be to print it out correctly, I"ll post it on here.

I'm sure you'll be hearing from me soon ... that last program ... yeah, fun!
13 years ago

Originally posted by Satou kurinosuke:

Sorry ... I knew it was a big no-no to repost something already posted but in my ... tiredness, frustration, add whatever word you like here ... to figure this out, I posted a new question instead of adding to my already posted question which would've made more sense.

I'll consider my hand slapped and make sure not to do this again.
13 years ago

Originally posted by Satou kurinosuke:
[QB]As both methods are static, you can just call them, and get the returned value

I just tried plugging that into my real code and it gave me an error saying . <sigh> this is absolutely frustrating. Thanks anyway!
13 years ago
Ok, say I have 3 methods:

How do I call methods "metOne" and "metTwo" from the main method?? All of the information I can find on it is just confusing me even more.
13 years ago

Originally posted by Campbell Ritchie:
Alter the loop by adding a couple of check lines to it. That should allow you to see what is going wrong.

First piece of advice I took from you was to do the check lines. I did not alter anything else because I wanted to see what it would do.

The check came back, and it told me that x = everything that i wanted it to ... so it looks like I'm doing the main wrong. One of the instructions from the prof was to call the other two methods from the main method ... which I thought I was doing (but obviously not). That's what I'm working on now.

Thanks for the help!
13 years ago
This is what I'm supposed to do with my program:

In this project, we wish to see the growth of the function y = x + x^2 + 2^x. You should write a method, called calculateFunction, that calculates the value of y for various values of x. The declaration of this method is below:

public int calculateFunction(int x);

The calculateFunction method calculates the function y = x + x^2 + 2^x. To calculate the values of this expression, you can use:

x^2 = x * x
2^x = Math.pow(2,x)

Once the function has been calculated, print out the relative size of the result by calling the method printStars used in module 3 of the course modules. Calculate this function and print out its relative size for values from 1 to 10. Note that to make the number of stars reasonable, you should print out 1 star for each value of 10 returned (for example, if 62 is returned, you should print out 6 stars). You can do so by dividing by 10, noting that the value will be truncated to the next lowest int value.

This is what I've written:

It compiles correctly, but instead of giving me the following:

2 *
3 **
4 ***
5 ******
6 ************
7 ***************************
8 *****************************************************
9 *************************************************************************
10 ************************************************************************

It only gives me:


Please take a look at my code and give me some hints as to what exactly I'm missing. Any help would be greatly appreciated!
13 years ago
Here's my "final product!" Thanks again!!

13 years ago
I was really confused as to why the answer was 0 ... but when I went back and actually looked I realized my mistake. I didn't even think about that (obviously) but I feel so much better now!! You guys are seriously really awesome. I have learned more from you guys in 24 hrs than I have in the past couple of weeks in this class. Thank you!!!
13 years ago
WOOHOOOOO!!! I FIGURED IT OUT!!! Thanks Pete! I'm slow, but I eventually catch on!!
13 years ago
Ok, so I just did a little program on that, and it came back with 0. So. I was wrong and it should be 0.
13 years ago

Originally posted by pete stein:

What's going to print to the console here?

I feel a trick question coming on ...

I'd say 2000.
13 years ago

Originally posted by marc weber:

This might seem so "obvious" once you see it, but you might drive yourself crazy in the meantime. Think: Flow of execution.

//initialized to default value of 0.0...
double totalCollected;
//value printed out...
System.out.println ("\nYour total amount collected in US dollars is:" + totalCollected + "Goodbye!");
//reassigned new value...
totalCollected = dollars + euros + yen;

I've tried it both with totalCollected = dollars + euros + yen; and also with totalCollected = myDollars + myEuros + myYen; (since this last one is the actual place holders of the "collected" money) but both come out with the same at the end: 0.0 ... I'm wondering if maybe I have the reassignment sitting in the wrong place? It would seem to me that it should be under the following place:

Am I wrong in that thought? It didn't work under the main section ... and I'm not sure where else to put it besides under the variables section, but that didn't work either. I even tried this:

Same result. I'm about to go digging further into my book here to see if there's something that I missed. There has to be something!!
13 years ago

Posted by Pete Stein:-

quote:The problem is with these two lines: . . .

I did finally fix this problem, but still hasn't fixed my problem of getting more than 0.0 when I exit out of the program. I'm working on it though! Well, will be later tonight ... being Easter, we are about to head up to PA to visit some family so technically I shouldn't even be on the computer right now (I should be getting ready!!).

Those of use who are programming types remember what it was like to be beginners ourselves. I remember spending hours trying to work out what

quote:Gifts.java:45: illegal start of expression
public void enterUSdollars() { //enter US dollars amount

means, not realising I had simply put more {s than }s in the code. That is why we are willing to log on early on Sunday morning to try to help you.

And thank you Campbell! You guys are very dedicated to get up early on a Sunday morning to help me (and people like me)! And it's very appreciated by me, and I'm sure by many others!!

I hope you all have a wonderful Sunday (and Happy Easter, too)!!

Oh, and Pete ... thanks for the extra stuff to look at ... I'll definitely wait to add that confusion until after I've completely finished with the current (confusion) that I have

All the help is great ... and even though slightly confusing at times, it's good to see that there is more than one way to skin a pig! (I know I was supposed to say cat...but pig sounds so much better!! ha!!)

Thanks again guys!
13 years ago
Thanks! I finally got it to compile! WOOHOO!! I did run it ... and the only thing that's not doing right is that when I exit, instead of giving me the amount it all adds up to, it only gives me 0.0 ... but I'm determined to figure that one out on my own!!

Thank you EVERYONE for you help! I definitely would not have figured this out on my own! I did learn some stuff, so that is good ... and I know what to look for next time (the method inside method problem).

I can't say thank you enough!!
13 years ago
ok, but how do i pull them out of the do/while loop successfully? because i tried that already ... but still got the same errors that i'm currently receiving.
13 years ago