Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-25-2008, 05:01 PM   PM User | #1
Inquisit
New Coder

 
Join Date: Aug 2008
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Inquisit is an unknown quantity at this point
Question 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 >>>>>>>>
Inquisit is offline   Reply With Quote
Old 09-25-2008, 07:44 PM   PM User | #2
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
Quote:
Originally Posted by Inquisit View Post
ive tried the stack method of push pop etc no success in achieving if theres a simple method
what did u try?
__________________
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow
shyam is offline   Reply With Quote
Old 09-25-2008, 09:44 PM   PM User | #3
Inquisit
New Coder

 
Join Date: Aug 2008
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Inquisit is an unknown quantity at this point
Question

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??

Last edited by Inquisit; 09-25-2008 at 09:57 PM.. Reason: mistake
Inquisit is offline   Reply With Quote
Old 09-27-2008, 04:21 PM   PM User | #4
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
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;
  ...
  public double memoryAdd(double another) {
    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
__________________
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow
shyam is offline   Reply With Quote
Old 09-27-2008, 05:34 PM   PM User | #5
Inquisit
New Coder

 
Join Date: Aug 2008
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Inquisit is an unknown quantity at this point
Thumbs up

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

very helpful
Inquisit is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:46 AM.


Advertisement
Log in to turn off these ads.