• 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

I'm a big time trainee!

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, a simple program that adds two numbers and prints the sum.

now, i'm going to modify it so it takes those two numbers and prints the sum, product, difference and divided..

Do I put the method for the product, diff, etc in the same body as the original addition program? Or is it 4 different ones

I'm just looking for a hint so I can figure this out myself and stop ROTF
AT HOW big A major league trainee I am sounding like right now. It is kinda embarrassing..

But thanks for having mercy on me
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Joe!

You could add more logic to the body of the method that you already have. Or you could create new methods, one to encapsulate each different part of the logic you want to add.

I'd recommend working in very small steps. So, if you're thinking of adding four things, first add just one thing. Then compile and see if it works the way you thought and intended it would.

As you're new to this whole Java programming realm. I thought you might like to have at hand the following list of free on-line Java tutorials and books that I have found useful:
  • Sun's Java Tutorial
  • Introduction to Computer Science using Java by Bradley Kjell
  • Introduction to Programming Using Java by David J. Eck
  • Dick Baldwin's Java Programming Tutorials
  • Interactive Programming In Java by Lynn Andrea Stein
  • Bruce Eckel's Thinking In Java
  • JavaRanch's own Campfire Stories
  • Allen B. Downey's How To Think Like A Computer Scientist
  •  
    Joe Schlabotnik
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks Dirk.. Let me tell you where I got lost:

    sum = number1 + number2

    I thought "sum" was an official keyword, and i was wondering where product and quotient was at. The operators perform the magic.

    I will carry on now
     
    Dirk Schreckmann
    Sheriff
    Posts: 7023
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Joe, I'm not sure if you have a question or not. Do you?
     
    Ranch Hand
    Posts: 1272
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Joe:

    Can I have your autograph?

    Charlie Brown
     
    Joe Schlabotnik
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Dirk Schreckmann:
    Joe, I'm not sure if you have a question or not. Do you?



    What I meant to say was, hmmm It's hard to explain.. OK, i thought that "sum" was some official keyword in java.. But it's not. So when i want to add , subtract, divide and then multiply 2 different numbers. I'm looking at my textbook, that gives me the example of adding two numbers. I saw sum = number1 + number2. So in my infinite ignorant trainee wisdom, I wondered where is the official term for multiplying, or dividing or subtracting? I did not see it so I posted here.. I later learned, that the word "sum" could be named "fizwig"; java would not care.. It's only interested in the operators of number + number2 or number 1 / number 2 or number1 * number2 etc etc.. And for us trainees this turns the light bulb on (In other words to add numbers you can use fizwig for the terms but to accomplish the results / * + and - are the puppies you need to know) We trainees need this type of common man explanations to learn this brand new world. I struggled for several hours a day studying trying to grasp this concept.

    12 years ago, I use to run a BBS.. Writing DOS batchfiles like if exist, goto, if errorlevel, :label, etc i thought was tough.. But this is harder.
     
    Joe Schlabotnik
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Mike Gershman:
    Joe:

    Can I have your autograph?

    Charlie Brown



    Only on the official Joe Schlabnotnik playing card! :[D
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic