Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Old 11-11-2008, 01:44 PM Java Applet help
millwalll's Avatar
Webmaster Talker

Posts: 674
Name: James
Location: KENT
Trades: 3
Hi all,

Need some help I am writing a very small applet and stuck on somthing, I have tried everythink I can think off.I know it gonna be somthing silly but just cant work it out.

Code:
double x;
  String total;
  String newtotal;
  
      try {
      String xStr = txtAmount.getText();
      x = Double.parseDouble(xStr);
   }
   catch (NumberFormatException e) {
          // The string xStr is not a legal number.
      txtAmount.setText("Illegal data for x.");
      return;
   
   }
  
      total = ( "£" + (x*12));
      txtYear.setText(total);
      newtotal =((y/365) +"p");
      txtDay.setText(newtotal);
Ok what happen there are 3 textboxes, the user inputs a price in the top one txtAmount.
This then times this by 12 to give a price for a year. I need this value to go into the next box what is txtYear this all works fine.

The bit I cant do is the next bit, I need to take the value from the txtYear and divide it by 365 and place the newtotal into txtday.

any help would be amazing as it really starting to p me off

thanks again
__________________

Please login or register to view this content. Registration is FREE
millwalll is offline
Reply With Quote
View Public Profile Visit millwalll's homepage!
 
 
Register now for full access!
Old 11-11-2008, 02:00 PM Re: Java Applet help
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Code:
      txtYear.setText(( "£" + (x*12)));
      txtDay.setText(( (x*12)/365) + "p"));
Looks about right
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-11-2008, 02:04 PM Re: Java Applet help
millwalll's Avatar
Webmaster Talker

Posts: 674
Name: James
Location: KENT
Trades: 3
thanks a lot my god I could so kick myself next question this gives me 0.22980821917808217 how can I get it to only show 0.22
__________________

Please login or register to view this content. Registration is FREE
millwalll is offline
Reply With Quote
View Public Profile Visit millwalll's homepage!
 
Reply     « Reply to Java Applet help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31661 seconds with 12 queries