Nathan banks

Greenhorn
+ Follow
since Aug 01, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
17
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nathan banks

Okay, so I now understand what you were showing me.  For a moment I thought that you there was another type of comment that also allowed the assigning of a variable.  It's the semicolon at the end of the comments fault.  I now (hopefully) understand you were showing me what happens if I don't assign it a value before it's initialized (turn it into a comment and it doesn't get assigned a value).  Wow, thanks for bearing with me.

Ganesh Patekar wrote:

  • Good to read click here --->Java Programming Style Guide

  •  Also, this is a great link.  I need to commit to memory more of what I read.  I have visited this page before, but that was about a week ago.  As I continue to learn more I should revisit pages like this so that I can be sure I am doing everything correctly.  For example, my books exercises do not have the keyword for followed by a space    Thanks again
    7 years ago

    Ganesh Patekar wrote:No no you are just writing comment but not commenting assignment statement counter = 0; on line no 5.

    Oh, okay.  I didn't know you could assign a comment statement.  I'll check out the link.  Thanks!
    7 years ago
    Ok, so i should have probably started by saying that this is a chapter 1 exercise from "Java A Beginner Guide Sixth Edition by Herbert Schildt."

    Ganesh Patekar wrote:Are you sure? I'm talking about commenting counter = 0 on line no 5.. verify again.

     I did run it again and I got the expected results from the exercise.  Maybe I'm misunderstanding what you're asking me to try.  I inserted the comment after I gave counter a value of 0  I will study the link you gave me more tomorrow (its late now) and I thank you. You cleared up a lot!

    Julian West wrote:
    - Indent! heh
    - You can just use gallons as a counter and ditch the counter logic; use gallons % 10 (modulus operator) instead
    - You can use printf or String.format to format your numbers to a fixed size and spacing
    - You can make gallons an int and you can declare it in the For loop
    - You can declare litres in the for loop since it isn't used outside the loop



    This is also terrific.  I did indent in notepad++, I guess, it looked indented anyhow.    You gave me a lot of great tips that I have no grasp of yet, but I will delve into your advice and try to better understand it.  I'm pretty new at this, so it's all very helpful.  Thank you both!
    7 years ago
    Well, my idiot self realized I could very easily test what you were telling me so I ran it again with
    and I got the same (correct) results.  I guess it is not part of the loop.
    7 years ago
    Thank you for your help Ganesh.

    Ganesh Patekar wrote:You can initialize counter in loop Or outside loop doesn't matter, just need to initialize before It's use. But If you initialize counter in loop then each time loop executes It'll again assign same value to counter.

     Is the block (i think its a block) containing counter++ part of the loop.  If I assigned counter a value one line before counter++ does that make it part of the loop?  Also, the program ran without errors with and without the comment // counter = 0
    7 years ago
    I am re-reading my books first chapter to beat these concepts into my head.  I am trying to figure out if the for loops target is a block, which also encompass the if statements block.  I think so but would love to be sure.  Also, does the counter need to be initialized before the for loop?  Thanks for any help,
    7 years ago
    Welcome Steve.  I am brand new to Java and was also searching for a place that I could find real, human to human interaction.  I have already found the community at coderanch to be kind, knoweladgable and helpful.  The site is also filled with great information, so dive in and have fun!
    7 years ago

    Jeanne Boyarsky wrote:Welcome Nathan. Have a cow for being the post that inspired a new users introductions forum.

    Hey, Thanks!  My first cow!  The JavaRanch has already been very inspiring to me, so I'm glad to have any sort of meaningful impact here.
    7 years ago
     Wow, 25.5lbs.  Now that is light!

    Thanks Paul  
    7 years ago

    Paul Clapham wrote: Does the output for your lunar weight come out as 17% of your earth weight?

     :eek: I thought it was supposed to be 17% less than earth weight!  Yikes, i better fix that!
    7 years ago
    So, I'm going kind of slowly, but I'm trying to let what i learn sink in, so that i can better understand and remember it.  This is from the chapter 1 self test in a book I'm reading.  Feel free to critique.
    "9. The moon’s gravity is about 17 percent that of earth’s. Write a program that computes your effective weight on the moon."

    7 years ago

    Campbell Ritchie wrote:No, it won't. If it takes longer, that is because you are using the wrong text editor. The suggestions in this post will allow you to use a text editor to code more quickly and to find formatting errors more easily.

    Hey, that's terrific!  Thank you for even more helpful info.  I'm really glad I decided early on to sing up for an account and dive into the forums.  It's out of character for me, but I'm happy here already.
    7 years ago

    Ganesh Patekar wrote:Nathan, Worth reading click here -->Java Programming Style Guide



    Within seconds I learned that I should not be using the tab key.  Mistakes, mistakes mistakes.  This is going to make typing take quite a bit longer!  I'll keep reading, and plugging away at my book and exercises as well.  Thanks!
    7 years ago
    This is good information.

    Liutauras Vilda wrote:One more thing. Variable names if these aren't constants (forget about those for a while) suppose to start with a lower case (this is how the Java coding convention states).

    I thought was what i read.  I wasn't sure if you were trying to test me/see if I would catch it when you wrote:

    Liutauras Vilda wrote:For instance JavaScript:
    [code=javascript]var name = "Nathan";

     I actually tried it both ways (probably more like 6 ways until I got it to run right.)  I figured I would post the results with "Nathan", but I am now more clear on the convention.
    7 years ago

    Liutauras Vilda wrote:One thing, I'd suggest not to use such variable name as "var", because in some other programming languages it is an identifier to declare a variable.


    This was definitely causing a lot of my confusion.  I see now that the name of the variable was var!  This is an exercise from a book, and I overlooked the fact that "var" was the name for the variable.  In fairness, the author explains that it is "a variable called var," but I am trying to understand a lot of new information and that got lost in my head.  Still, he could have called it "cats" or "pickle" or anything else and I would have probably been less confused  

    Liutauras Vilda wrote:



    So I changed it all up
    I changed all of the subsequent "vars" to Nathan, and felt great when I got it to run.

    Thank you Liutauras and again, everyone for your help.
    7 years ago