How do I git gud at programming? I understand the concepts but when it building a program for homework assignments I usually just stare at the screen not knowing what steps to take. I'm pretty solid with my math classes but for some reason baby's first programming course is a pain in the ass for me.
You keep trying until you've got the result you wanted.
You can't think and plan perfect code that will Work 100% from thought alone.
You get an idea and you start adding to it a little bit at a time
Here are some random ideas
1) Having an idea, and just trying a lot of things to make it work
2) Having deligence to simplify your ideas, even if your first incarnation is not perfect you can make it better
3) Having a good environment. A lot of people fail at this step because, for example, working with IDEs and complex GUI environments is difficult because it's hard to organize libraries/dependencies, and on the flipside, but doing everything from the command line, although arguably better, has a steeper learning curve
anyways, if you have a specific language it might help add more context
Thanks for the replies. I have to use Java is that helps at all.
Yeah this seems to work most of the time I guess I'm just more worried about exam time when I have to get everything right the first time. I've started to write out flowcharts and it helps a bit.
I have to write a program that requires me to find the number of sevens between two numbers. Ex. 100-150, there are 5 7s (107,117,127,137,147), but for 100-180, there are 9, because 177 counts for two sevens. I figure I should use mod using a for loop but other than that I'm pretty lost.
this is a very common beginners problem.
basically, how do you "get" a digit in a number?
the trick is to use modulus AND division (at least this is how it is in most textbooks), specifically, using INTEGER division, which knocks off the remaining
177 mod 10 = 7 <-- count a 7 here
177/10 = 17
17mod 10 = 7 <-- count a 7 here
17/10 = 1
1mod10 = 1 <-- not a seven here
A do while will solve your problem. Do (starting number +7) while(starting number less than goal number) and each time you loop through the Do black, just add one to a running count and output the count at the end. Any questions, class?
It sometimes helps to write it out in pseudo code after figuring out the individual steps on paper.
You need to check every digit of every number in the sequence. So something like:
for [number] in all numbers between 100 and 150:
for [digit] in all digits in [number]:
if this digit == 7, add one to your count
There was a particular class in college that just made things click for me. The most similar thing I can find that's generally available is the book "Seven Languages in Seven Weeks": a crash course on a whole bunch of different languages at once.
The reason the class worked for me is that having to deal with so many languages so quickly forced me to learn to look beyond the constraints of language, or even paradigm. The book may help do the same for you,