Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Storing numbers and recalling numbers ?

1. ## Storing numbers and recalling numbers ?

Storing numbers and recalling Question

Lets say you've entered a value displays the output i.e

String s;
float A;
double Number;
s=TextFieldValueA.getText();
A=Integer.parseInt(s);
Number= (double)Math.round(A);
s=String.valueOf(Number);
txtNumber.setText(s);

now when you select store on the menu it stores the number

"ValueOf(Number)" and TextField A just like when you click store buttton on a calcutor M+ and M- to recall that number

and
to recall the Stored Values to be displayed on the textfields Number and A
when recall is selected this can be done in Pascal when programming your calculator like the TI 84 Silver

i.e 1-(sto)-> A A= 1 rcl A, A=1

ive tried the stack method of push pop etc no success in achieving if theres a simple method your help would be appreciated on this one

Thanks >>>>>>>>

• Originally Posted by Inquisit
ive tried the stack method of push pop etc no success in achieving if theres a simple method
what did u try?

• example ive used the node method trial

Code:
```class Node{
String item;
Node next;
Node first= new Node();
Node Second=new Node();
Node third=new Node();

first.item ="1";
second.item="2";
third.item="3"
first.next= second;
second.next= third
third.next=null;```
didnt work

Code:
```public String toString() {
String s= "";
for (Node x= first;
x!= null;
x=x.next;)
s += x.item +"";
return s;```
didnt work

stack method

StackClass stack1=new StackClass();
try
{
stack1.push(new IntElement(1); got sophisticated so left it out

i need just to make it simple thats all

M+ (memory store button is clicked) stores the values
M- (Memory recall button is clicked ) recalls the values as mentioned earlier

when the recall button is clicked it sets the stored numbers back on the textField A and Number using setText("") method its possible with a calculator like microsoft calculator as you know why not java if not any thing is possible

Your help im really stuck on this one i know it is straight forward any suggestions??

• Aren't you overcomplicating things? IMHO all you need is a single instance variable to hold the contents of the _memory_

Code:
```class Calculator {
double memory;
TextField textField;
...
memory += another;
return memory;
}
public double memorySubtract(double another) {
memory -= another;
return memory;
}
public void memoryClear() {
memory = 0;
}
public void memoryStore() {
memory = Double.parseDouble(textField.getText());
}
public void memoryRecall() {
textField.setText(String.valueOf(memory));
}
...
}```
this should give you a fair idea

• Splendid God bless

i can now work my way into a complex solution

really appreciate thanks

just one question why cant i give a reputation round here i keep getting this message neeed to spread reputation first before.... so and so