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 4 of 4

Thread: math problem in java...

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    8
    My Mood
    Grumpy
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question math problem in java...

    Helloue!
    Today as i were at my chemistry lesson, my mind interrupted me when i was answering some questions, as i was using "raised by" in my answers i suddenly kept thinking "HOW DOW I DO THIS IN CODE(java)?!?", so i opened Eclipse(my chosen ide) and tested using that ^ symbol. i tested to print "answer" as "answer" was equal to 3^3, and i got the answer 6. Then i sunken in thoughts of how to do this.. i have used "raised by" in math before but i can't remember how to.

    In java ^ is pretty much an + sign.

    Plz help, THANKS!


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,699
    Thanks
    25
    Thanked 334 Times in 310 Posts

    Default Re: math problem in java...

    Math.pow(2,4) means 2^4
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. The Following User Says Thank You to aussiemcgr For This Useful Post:

    weirddan (January 17th, 2014)

  4. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,116
    My Mood
    Mellow
    Thanks
    244
    Thanked 755 Times in 741 Posts

    Default Re: math problem in java...

    As with most things in Java for which an operator does not exist, you would expect a method to do what you have asked. The method that raises one number to the power of another number is included in the Math class. Check that API for what you seek.

    I won't go into what '^' is or does, because you can also read about that by searching for java operators and reading yourself.

  5. The Following User Says Thank You to GregBrannon For This Useful Post:

    weirddan (January 17th, 2014)

  6. #4
    Junior Member
    Join Date
    Jan 2014
    Posts
    8
    My Mood
    Grumpy
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: math problem in java...

    Thank you!

Similar Threads

  1. i need help writing a code for a math problem
    By djjava in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 6th, 2013, 01:13 PM
  2. Basic Math Expression Java Problem
    By andyluvskrissy in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 15th, 2011, 03:22 AM
  3. Math program problem.
    By dylanka in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 27th, 2011, 04:44 PM
  4. Basic Math Expression Java Problem
    By andyluvskrissy in forum Object Oriented Programming
    Replies: 3
    Last Post: September 30th, 2010, 03:46 PM
  5. Math Problem
    By kidsforsale in forum What's Wrong With My Code?
    Replies: 11
    Last Post: September 14th, 2010, 05:09 PM