NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Simple Java Question -19NP reward

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 09-12-2005, 08:01 AM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: Aug 2003
Location: Texas
Posts: 384
ATWatts is on a distinguished road
 



Simple Java Question -19NP reward


How do you limit the number of digits that are displayed when outputting a number using Java. FOr example instead of 23.032345434 I want to display 23.03.

I'm trying to limit the digits shown on my little calculator at www.GasCreditCard.biz.

19 NP to whoever answers my question correctly first. That means that the answer directly has to lead to my problem being fixed.
????: NamePros.com http://www.namepros.com/programming/123035-simple-java-question-19np-reward.html

Code:
function calculatesavings(form)
{
MPG = form.MPG.value;
MDPY = form.MDPY.value;
PPG = form.PPG.value;
GTS = form.GTS.value;
G=MDPY/MPG;
CWS=G*PPG;
SPY=CWS*.1;
SPM=SPY/12;
SPG=.1*PPG;
SPT=SPG*GTS;
form.SPY.value=SPY;
form.SPM.value=SPM;
form.SPT.value=SPT;
form.SPG.value=SPG;
}
</script>
Last edited by ATWatts; 09-12-2005 at 08:06 AM.
ATWatts is offline  
Old 09-12-2005, 09:37 AM   #2 (permalink)
Senior Member
 
dgaussin's Avatar
Join Date: May 2004
Location: France
Posts: 1,226
dgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to beholddgaussin is a splendid one to behold
 




Try that :

Code:
function calculatesavings(form)
{
MPG = form.MPG.value;
MDPY = form.MDPY.value;
PPG = form.PPG.value;
GTS = form.GTS.value;
G=MDPY/MPG;
CWS=G*PPG;
SPY=CWS*.1;
SPM=SPY/12;
SPG=.1*PPG;
SPT=SPG*GTS;
form.SPY.value=Math.round(SPY*100)/100;
form.SPM.value=Math.round(SPM*100)/100;
form.SPT.value=Math.round(SPT*100)/100;
form.SPG.value=Math.round(SPG*100)/100;
}
</script>
dgaussin is offline  
Old 09-12-2005, 01:50 PM THREAD STARTER               #3 (permalink)
NamePros Regular
Join Date: Aug 2003
Location: Texas
Posts: 384
ATWatts is on a distinguished road
 



Thanks


Thanks!!
ATWatts is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple domain question 4 non newbies rcep Domain Newbies 0 08-21-2005 01:52 PM
Simple but silly question - Paths/tags geezdesign Programming 7 07-03-2004 01:43 PM
Simple image question ccc Web Design Discussion 3 06-19-2004 01:31 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 06:56 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger