Results 1 to 5 of 5
  1. #1
    Propinquity is offline Member
    Join Date
    Oct 2013
    Posts
    63
    Rep Power
    0

    Default Please help me with this project?

    Hello, I am trying to make a simple calculator.
    I am very new to Java (I started learning around 3 days ago) so bear with me and my lack of knowledge. Sorry and thank you for any help you can provide!

    Basically, what I want it to do is when it starts up, it'll greet the user and ask which of the following six functions they want to perform:
    addition, subtraction, multiplication, division, exponentiation and square root. Then it should ask about the appropriate number of operands for the function (the user will input a number)
    Then it should print the calculation that will be performed, perform it, then print the result.

    I am not sure how to accomplish the user input aspect. Do I use "if" statements? I am not sure.
    I am really just unsure on how to do all of this.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: Please help me with this project?

    Using an if statement (else if) would be a good start.

  3. #3
    Propinquity is offline Member
    Join Date
    Oct 2013
    Posts
    63
    Rep Power
    0

    Default Re: Please help me with this project?

    Quote Originally Posted by Junky View Post
    Using an if statement (else if) would be a good start.
    Okay, I've worked out how to do the basic operations.
    The thing which I'm stuck on is how to get negative numbers to work correctly for the square root operator.
    Also, I don't really know how to get the program to perform more than one calculation without restarting the program. Do you know how I might accomplish this?

  4. #4
    ras_oscar is offline Member
    Join Date
    Jun 2013
    Posts
    60
    Rep Power
    0

    Default Re: Please help me with this project?

    Perhaps put the entire program in a while loop and ask if the user wishes to exit. (Y,N)

  5. #5
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,017
    Rep Power
    6

    Default Re: Please help me with this project?

    Quote Originally Posted by Propinquity View Post
    The thing which I'm stuck on is how to get negative numbers to work correctly for the square root operator.
    They don't. However, unless you are going to handle complex numbers, you should simply flag the value as
    an error before you take the square root. Also, don't forget about division by zero.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 7
    Last Post: 11-27-2012, 11:16 AM
  2. Replies: 1
    Last Post: 05-17-2012, 10:43 PM
  3. Creating a project in eclipse from existing project
    By Suraiya in forum New To Java
    Replies: 1
    Last Post: 10-08-2011, 10:14 AM
  4. open existing project project ..
    By itaipee in forum Eclipse
    Replies: 1
    Last Post: 12-28-2008, 09:12 PM

Posting Permissions

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