Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculator program

Status
Not open for further replies.

cindyg919

Programmer
Feb 10, 2001
17
US
i am writing a program and i need help with it please. the program is:
write a simple calculator. each valid command for this calculator should consist of an operation followed by an operand. this is an accumulator-based calculator, meaning, each arithmetic operator only takes a single number. the original accumulator value is 0 and every successive operation will be on this value.the calculator should display the accumulator value after each operation.
using these keys: + add, - subtract, * multiply,
/divide, ^ power, q quit
i want the results to come out like this:
+5
result so far is 5.0
^2
result so far is 25.0
/ 2
result so far is 12.5
q 0
final result is 12.5

*********ARRAYS CANNOT BE USED IN THIS PROGRAM*************
 
Why don't you start writing the code and when you get to a point where you are having trouble, ask a specific question. It does you no good to have someone here write the entire program for you. Here I'll start you off:

Code:
public class Calculator {
   
   public void static main(String args []) {
      
      /* 
       * Most of your code will go 
       * in this method.  You will 
       * probably be using a switch
       * statement nested inside a
       * while loop.
       */ 

   }

   /* 
    *  May want to declare some static 
    *  instance variables here 
    */
}

That should be enough to get you started. Write back with specific questions if you need more help.

Wushutwist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top