Results 1 to 18 of 18
  1. #1
    thirdyberdejo is offline Member
    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0

    Default 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 07:36 AM.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default 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. #3
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,040
    Rep Power
    20

    Default Re: hi!..please help..

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

  4. #4
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default 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.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  5. #5
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default 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. #6
    thirdyberdejo is offline Member
    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0

    Default 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. #7
    thirdyberdejo is offline Member
    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0

    Default 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. #8
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,040
    Rep Power
    20

    Default Re: hi!..please help..

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

  9. #9
    thirdyberdejo is offline Member
    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0

    Default Re: hi!..please help..

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

  10. #10
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,040
    Rep Power
    20

    Default Re: hi!..please help..

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

  11. #11
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default 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. #12
    thirdyberdejo is offline Member
    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0

    Default 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. #13
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default 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. #14
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: hi!..please help..

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

  15. #15
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default 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. #16
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default 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. #17
    thirdyberdejo is offline Member
    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0

    Default Re: hi!..please help..

    can u help me for javascript?

  18. #18
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default 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
  •