• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need help with assignment

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 53
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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: 79151
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    Ranch Hand
    Posts: 94
    3
    Eclipse IDE Oracle AngularJS C++ Chrome Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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: 53
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I got it


                             
                               
     
    Sheriff
    Posts: 7125
    184
    Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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: 53
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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: 7125
    184
    Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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: 53
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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: 79151
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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:-
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic