• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help with assignment  RSS feed

 
Ed Palazo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Total noob.  Please help.  How do I set this up?
I understand some of the concepts but still hard to understand.
IMG_5900.PNG
[Thumbnail for IMG_5900.PNG]
 
Carey Brown
Saloon Keeper
Posts: 3323
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried so far? Have you ever written "Hello world"? Then you should at least be able to display a prompt.
 
Campbell Ritchie
Marshal
Posts: 56545
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Two hints:-
  • 1: Don't use this for r²
  • 2: Use this for π.
  • [edit]If you are to use your own constant, copy that value of π into your constant.
     
    Ed Palazo
    Ranch Hand
    Posts: 40
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Carey Brown wrote:What have you tried so far? Have you ever written "Hello world"? Then you should at least be able to display a prompt.


    Oh so should I just use that outline basically?
     
    Campbell Ritchie
    Marshal
    Posts: 56545
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I would suggest you shou‍ld turn your PC off and write down on paper how you intend to do that exercise. Once you have that written, you will find it easier. You might do better to attempt part of it, and leave the remainder until you have the part working reliably.
     
    Daniel Andres
    Ranch Hand
    Posts: 94
    3
    AngularJS C++ Chrome Eclipse IDE Oracle Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    While it may not be necessary, I'm glad I took java pseudo code first. You "code" so many programs on paper that it becomes a habit to use algorithms first before sitting down in front of a pc.

    Having an outline of what you need to do should always be a plus for programmers.

     
    Ed Palazo
    Ranch Hand
    Posts: 40
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I got it


                              
                               
     
    Knute Snortum
    Sheriff
    Posts: 4279
    127
    Chrome Eclipse IDE Java Postgres Database VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Good job!  A couple of things about your code:

    * Although it might seem silly, practice getting most of your code out of the main() method.  You can read about it here.

    * Don't use Math.pow() for squaring a number.  Just write radius * radius.

    * In general, you should declare variables just as you need them, so:

    * "A" is not a good variable name, first because the naming convention is that a variable should begin with a lowercase letter, and second because it isn't clear what the variable is.  Use "area" instead.
     
    Ed Palazo
    Ranch Hand
    Posts: 40
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    How would I make it so it takes in numbers with decimals for radius?  Help with that please??
     
    Knute Snortum
    Sheriff
    Posts: 4279
    127
    Chrome Eclipse IDE Java Postgres Database VI Editor
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Search the documentation for Scanner, close to the nextInt() method, and you should find your answer.  This is a good skill to master when you're learning to program.

    Here is the URL to the documentation:

    https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html

    You can find it yourself by Googling "Java 8 Scanner".
     
    Ed Palazo
    Ranch Hand
    Posts: 40
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Knute Snortum wrote:Search the documentation for Scanner, close to the nextInt() method, and you should find your answer.  This is a good skill to master when you're learning to program.

    Here is the URL to the documentation:

    https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html

    You can find it yourself by Googling "Java 8 Scanner".


    thanks bruh bruh
     
    Campbell Ritchie
    Marshal
    Posts: 56545
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    There is something you are missing. It says to make π a constant. You are going to have to make your own constant and copy the value of Math.PI into it. I know it seems daft, but you have to follow the instructions given if you want full marks. In real life, I would writeIt might be better to make yourself a utility class with this sort of method in:-
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!