• Post Reply Bookmark Topic Watch Topic
  • New Topic

Output current value stored  RSS feed

 
kennith stomps
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a calculator code, which is to add, subtract, multiply, and divide two operands of the users input. The calculator is also supposed to keep track of and display the current value stored. I have been trying to find some syntax on ways this is to be done, and am not having any luck. What would you  recommend?
 
Grant Callant
Greenhorn
Posts: 11
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kennith,

I'm not sure what you mean by
I have been trying to find some syntax on ways this is to be done
Syntax is referring to the way words and characters are placed together, in order to create meaning. For instance, English grammar has a certain syntax ("i before e, except after c"... etc). I'm assuming that you meant a pattern, or a plan. A wise user here (Winston) first told me, when you first are coding- think about the what, not the how. The easiest way to do this is on pencil and paper.

You want to make a calculator- what does a calculator need in order to function? Don't think about how it works, just what. It needs a screen, buttons, batteries, the buttons need to map to different appropriate functions... etc. In the same way, your Calculator program needs some functionality, like the ability to take input from the user; decide if the input is valid input; logically decide what to do with that input; operate on the input (add, subtract etc); keep track of values and display the values in some way (via console or a gui).

To show you what I mean with a really general example (notice I'm not describing how to do these things yet- I'm just mapping out what is needed):



Hopefully this helps you get started!


-Grant
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!