Joshua Friedman

Greenhorn
+ Follow
since Jun 16, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Joshua Friedman

Hello!

I've solved the dreaded pyramid problem from the itunes Stanford CS106 course, and created myself a pyramid (hint to those having trouble, try manually coding your first two lines in order to figure out what exactly you want your for loops to do. I could have saved myself about a week of mental anguish if I did that!).

Two issues:

1) The pyramid is not quite centered and I'm having trouble figuring out how to do this: is there a set formula to use and memorize from here on out, or do I need to rework my algorithm?

2) How would you fix this code? If I were an actual CS106 student I'd have a prof and some TAs to help me out...but now I don't so I need your experience . Right now, I have each individual layer being laid from left to right, then measuring to go up by one layer, shift the row by 1/2 a brick length, and lay down one less brick per layer until we have one brick. Is there a better way to go about this that I didn't think of?

Thank you very much!


10 years ago
K. Tsang,

Thanks a lot for your reply. You're right, I DID make a mistake in the sign, but even if I change the sign the number never increments and just puts a number of whatever I assigned "date" to be in the square.
10 years ago
Hello!

This is my first post. I am an absolute, total beginner in learning CS and am working through the art and science of Java book to teach myself Java, using a version of Stanford's cs106a class that's on itunes. I'm having a trouble with one of the problems.

I'm supposed to create a very basic calendar that includes the date of the month. On this calendar (stretched from Sunday to Saturday), the month would start on Friday. The number of weeks should also change based upon how many days there are in the month. Instead I get rows of squares, each containing a "0" My code is here:



What ends up happening under these conditions looks like the attached picture. Can anyone here please help me figure out what exactly is going on in these loops and why my dates won't show up properly?

As a related question, what exactly ARE I and J? I imagine the machine as drawing these squares left to right, then moving down, and drawing another row. Using the pause method shows me that's what is happening but as a beginner I'm feeling very, very lost. Any help would be appreciated!


*edit attached a picture of my results
10 years ago