Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Trying to make a simple java program

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Trying to make a simple java program

    Hi. I'm trying to make a basic program where some variables can be entered. After they are entered, I want a few basic equations to be done and then some text to be displayed with the resulting number. I used basic java a couple of months ago and I have forgotten most of it. I was wondering if anybody could help me out. You don't need you to write it for me completely (but if you want, feel free to), just give me some tips and maybe a few lines would be great. Also, I have DESPERATELY been trying to locate a program to write java code and then compile and run said code. Are there any programs that are free to download where I can do this? I am using a Macbook running on Mac OS X 10.5.8. Thanks guys! I'd wish you all good luck, but this is probably baby-work for you

    Here's a quick little diagram of what I am aiming for. Just in case it's confusing, "->" is supposed to be "stored as" and it all goes in the order I'm looking for. Letters in (), I want to be able to enter it in as a number and the letters I used can be changed:

    (X)*(1.8) -> A (J)*(1.8) -> M
    (Y)*(1.2) -> B (K)*(1.2) -> N
    (Z)*(0.6) -> C (L)*(0.6) -> O
    A+B+C -> D
    M+N+O -> P
    D+P -> E
    D/E -> G
    P/E -> H
    G*(100) -> S
    H*(100) -> T
    "The final number is 'S' percent" (Display the percent symbol if you can)
    "The final number is 'T' percent" (Display the percent symbol if you can)


  2. #2
    Junior Member
    Join Date
    Oct 2011
    Location
    United Kingdom
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Trying to make a simple java program

    You could use Eclipse, it's free and can be used on Mac. Eclipse Downloads download the Eclipse IDE for Java EE Developers version.

  3. #3
    Member
    Join Date
    Oct 2011
    Posts
    42
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: Trying to make a simple java program

    Hi, I have some suggestions for you:
    - Declare variables to store the value input from user: X, Y, Z, J, K, L...
    - use System.in.readLine() to read input from user, then store the value into variables.
    - use math operators to do the calculation.
    - use System.out.println() to show message and display result to user.

    java exception
    Last edited by hns1984; January 11th, 2012 at 05:51 PM.

  4. #4
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Trying to make a simple java program

    You must look into THIS!!!

  5. #5
    Member
    Join Date
    Oct 2011
    Posts
    114
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Trying to make a simple java program

    Quote Originally Posted by hns1984 View Post
    Hi, I have some suggestions for you:

    - use System.in.readLine() to read input from user, then store the value into variables.
    Im only a beginner but may i ask why this instead of Scanner class? Its just im interested as ive ony been taught the Scanner class to read in user input.

  6. #6
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,470
    My Mood
    Grumpy
    Thanks
    0
    Thanked 160 Times in 151 Posts

    Default Re: Trying to make a simple java program

    Even waaaay back when I learnt Java we were not advised to use System.in directly, rather we wrapped it in a BufferedReader object. So I would never advise anyone to use System.in directly. Using Scanner is fine.
    Improving the world one idiot at a time!

  7. #7
    Member
    Join Date
    Oct 2011
    Posts
    42
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: Trying to make a simple java program

    Quote Originally Posted by Junky View Post
    Even waaaay back when I learnt Java we were not advised to use System.in directly, rather we wrapped it in a BufferedReader object. So I would never advise anyone to use System.in directly. Using Scanner is fine.
    Can you explain why using BufferedReader or Scanner instead of System.in?

    java exception
    Last edited by hns1984; January 11th, 2012 at 05:52 PM.

Similar Threads

  1. Simple Java Program - hasTeen [HELP]
    By HeroFlame in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 24th, 2011, 09:16 AM
  2. Simple Java Program
    By Robbiep in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 24th, 2011, 07:27 AM
  3. PLEASE HELP!!!! simple java program...
    By parvez07 in forum Object Oriented Programming
    Replies: 5
    Last Post: August 26th, 2009, 06:38 AM
  4. help with simple java program
    By parvez07 in forum Java Theory & Questions
    Replies: 4
    Last Post: August 25th, 2009, 07:19 AM
  5. Java program to write game
    By GrosslyMisinformed in forum Paid Java Projects
    Replies: 3
    Last Post: January 27th, 2009, 02:33 PM

Tags for this Thread