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)
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.
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
Re: Trying to make a simple java program
You must look into THIS!!!
Re: Trying to make a simple java program
Quote:
Originally Posted by
hns1984
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.
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.
Re: Trying to make a simple java program
Quote:
Originally Posted by
Junky
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