# Thread: hi!..please help..

1. Member
Join Date
Dec 2011
Posts
6
Rep Power
0

## hi!..please help..

how to add and subtract in java program

example: 9 - 600 = 591 ....... if the input is 9 the 600 is automatically subtract and the output is 591 ...
Last edited by thirdyberdejo; 12-06-2011 at 08:36 AM.

2. ## Re: hi!..please help..

how to add and subtract in java program
You could use an expression in an assignment statement to add and/or subtract. An expression is two operands with an operator between them and perhaps surrounded by ()s: 44+2 or 7-3
Post the code you are working on so we can see your problems.
Also post the full text of any error messages.

3. Moderator
Join Date
Apr 2009
Posts
13,067
Rep Power
23

## Re: hi!..please help..

9 - 600 != 591
9 - 600 = -591.

4. ## Re: hi!..please help..

@Tolls, I believe the OP wants to know how to make it so the smaller number is automatically subtracted from the larger. So if the two inputs were 9 and 600, the output would be 591.

@OP, if I assume correctly, you will need to get the two inputs. Then you will need to compare them in an if, ie:
Java Code:
```if (a>b) {//Subtract b from a}
else {//Subtract a from b}```
Do you have any code to show us? That might help us clarify a little better.

5. ## Re: hi!..please help..

If that is what you want it may be helpful to just use an absolute value method. Check the Math class.

6. Member
Join Date
Dec 2011
Posts
6
Rep Power
0

## Re: hi!..please help..

i dont have no codes to show you...because i'm a beginner and i need the full codes...can you help for this?... please help me..

7. Member
Join Date
Dec 2011
Posts
6
Rep Power
0

## Re: hi!..please help..

I dont have codes to show you...because i'm a beginner and i need the full codes...can you help for this?... please help me..

8. Moderator
Join Date
Apr 2009
Posts
13,067
Rep Power
23

## Re: hi!..please help..

No.
We don't do that sort of thing around here.

9. Member
Join Date
Dec 2011
Posts
6
Rep Power
0

## Re: hi!..please help..

so what can i do for my problem..please help..

10. Moderator
Join Date
Apr 2009
Posts
13,067
Rep Power
23

## Re: hi!..please help..

Write some code?
That tends to be how you learn.

11. ## Re: hi!..please help..

What is the purpose of your request for help?
Do you want to learn how to program in java?
Or do you want some code you can hand in to your professor?

12. Member
Join Date
Dec 2011
Posts
6
Rep Power
0

## Re: hi!..please help..

yes i want to learn about java program..my problems is i want to create an timecard in using java program and i don't know how i start..

13. ## Re: hi!..please help..

I guess you should read some tutorials about how to program in java.
I don't have any links to really basic tutorials. Here are some I have:
The Java™ Tutorials
The Really Big Index

14. ## Re: hi!..please help..

Originally Posted by thirdyberdejo
so what can i do for my problem..please help..
The answer was provided in reply #5. Please read all replies in future.

15. ## Re: hi!..please help..

I get the feeling this OP is trying to figure out how to write any program even the HelloWorld program.

16. ## Re: hi!..please help..

If it is HelloWorld, I'll gladly write it for him:

Java Code:
```public class Hello{
public static void main(String[] args){
System.out.println("Hello, World!");
}
}```

17. Member
Join Date
Dec 2011
Posts
6
Rep Power
0

## Re: hi!..please help..

can u help me for javascript?

18. ## Re: hi!..please help..

Try a javascript forum for help with javascript problems.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•