Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

addition formula is returning wrong result

Status
Not open for further replies.

thibault

Programmer
Sep 8, 1999
44
US
below is code from one of my pages.&nbsp;&nbsp;the cost() function is supposed to add up the values of tAdult, tChild, tSenior and pParking.&nbsp;&nbsp;then the display() function is supposed to display it.&nbsp;&nbsp;unfortunately, when you choose santa's village, 2 adults and 1 child it returns this:<br><br>Adults:&nbsp;&nbsp;$37.9 <br>Children:&nbsp;&nbsp;$18.95 <br>Seniors:&nbsp;&nbsp;$0 <br>Parking:&nbsp;&nbsp;$0 <br>&nbsp;---------- <br>Total:&nbsp;&nbsp;$56.849999999999994 <br>See web site for Racing Rapids prices<br><br>tTotal should be $56.85(not $56.849999999.....), because that is the sum of 37.9 and 18.95.&nbsp;&nbsp;any ideas why it is doing this? ...and how i can fix it? <br><br><br><br>&lt;HTML&gt;<br>&nbsp;&lt;HEAD&gt;&lt;TITLE&gt;Layers and JavaScript&lt;/TITLE&gt;<br>&nbsp;&lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&gt;<br><br>var vCnt = 0;<br>var vAdult = 0;<br>var vChild = 0;<br>var vSenior = 0;<br>var vTotal = 0;<br>var pAdult = 0;<br>var pChild = 0;<br>var pSenior = 0;<br>var pTotal = 0;<br>var tAdult = 0;<br>var tChild = 0;<br>var tSenior = 0;<br>var pNotes;<br><br>function fWhere() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ind=document.formWhere.vWhere2.selectedIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;val=document.formWhere.vWhere2.options[ind].value;<br>&nbsp;&nbsp;&nbsp;&nbsp;switch(val) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;0&quot;:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAdult = 5;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pChild = 4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pSenior = 4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pParking = 5;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pNotes = &quot;Parking available near Mieg's Field&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (document.layers)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_adler&quot;].visibility='show',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_brookfield&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_field&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_shedd&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_santa&quot;].visibility='hide';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_adler&quot;].style.visibility='visible',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_brookfield&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_field&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_shedd&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_santa&quot;].style.visibility='hidden';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;1&quot;:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAdult = 7;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pChild = 3.5;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pSenior = 3.5;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pParking = 4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pNotes = &quot;Children ages 3 to 11&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (document.layers)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_adler&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_brookfield&quot;].visibility='show',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_field&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_shedd&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_santa&quot;].visibility='hide';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_adler&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_brookfield&quot;].style.visibility='visible',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_field&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_shedd&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_santa&quot;].style.visibility='hidden';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;2&quot;:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAdult = 8;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pChild = 4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pSenior = 4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pParking = 5;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pNotes = &quot;Children ages 3 to 11&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (document.layers)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_adler&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_brookfield&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_field&quot;].visibility='show',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_shedd&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_santa&quot;].visibility='hide';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_adler&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_brookfield&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_field&quot;].style.visibility='visible',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_shedd&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_santa&quot;].style.visibility='hidden';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;3&quot;:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAdult = 13;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pChild = 9;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pSenior = 9;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pParking = 5;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pNotes = &quot;Children ages 3 to 11&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (document.layers)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_adler&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_brookfield&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_field&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_shedd&quot;].visibility='show',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_santa&quot;].visibility='hide';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_adler&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_brookfield&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_field&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_shedd&quot;].style.visibility='visible',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_santa&quot;].style.visibility='hidden';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case &quot;4&quot;:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAdult = 18.95;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pChild = 18.95;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pSenior = 18.95;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pParking = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pNotes = &quot;See web site for Racing Rapids prices&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (document.layers)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_adler&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_brookfield&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_field&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_shedd&quot;].visibility='hide',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.layers[&quot;lyr_santa&quot;].visibility='show';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_adler&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_brookfield&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_field&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_shedd&quot;].style.visibility='hidden',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.all[&quot;lyr_santa&quot;].style.visibility='visible';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pAdult = 5;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pChild = 4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pSenior = 4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pParking = 5;<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;Adult();<br>&nbsp;&nbsp;&nbsp;Child();<br>&nbsp;&nbsp;&nbsp;Senior();<br>}<br><br><br>&nbsp;function Adult() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ind=document.formPeople.vAdultNum.selectedIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vAdult=document.formPeople.vAdultNum.options[ind].value;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tAdult = vAdult&nbsp;&nbsp;* pAdult;<br><br>}<br><br>&nbsp;function Child() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ind=document.formPeople.vChildNum.selectedIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vChild=document.formPeople.vChildNum.options[ind].value;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tChild = vChild * pChild;<br>}<br><br>&nbsp;function Senior() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ind=document.formPeople.vSeniorNum.selectedIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vSenior=document.formPeople.vSeniorNum.options[ind].value;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tSenior = vSenior * pSenior;<br>}<br><br><br>function Cost() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tTotal = tAdult + tChild + tSenior + pParking;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;display();<br>}<br><br>function display() {<br>&nbsp;&nbsp;&nbsp;DispWin = window.open('','NewWin', 'toolbar=no,status=no,width=300,height=200')<br>&nbsp;&nbsp;&nbsp;DispWin.document.write(&quot;&lt;TABLE&gt;&lt;TR&gt;&lt;TD&gt;&quot;);<br>&nbsp;&nbsp;&nbsp;DispWin.document.write(&quot;&lt;B&gt;Adults: &lt;/B&gt;&lt;/TD&gt;&lt;TD&gt;$&quot; + tAdult + &quot;&lt;/TD&gt;&lt;/TR&gt;&quot;);<br>&nbsp;&nbsp;&nbsp;DispWin.document.write(&quot;&lt;TR&gt;&lt;TD&gt;&lt;B&gt;Children: &lt;/B&gt;&lt;/TD&gt;&lt;TD&gt;$&quot; + tChild + &quot;&lt;/TD&gt;&lt;/TR&gt;&quot;);<br>&nbsp;&nbsp;&nbsp;DispWin.document.write(&quot;&lt;TR&gt;&lt;TD&gt;&lt;B&gt;Seniors: &lt;/B&gt;&lt;/TD&gt;&lt;TD&gt;$&quot; + tSenior + &quot;&lt;/TD&gt;&lt;/TR&gt;&quot;);<br>&nbsp;&nbsp;&nbsp;DispWin.document.write(&quot;&lt;TR&gt;&lt;TD&gt;&lt;B&gt;Parking: &lt;/B&gt;&lt;/TD&gt;&lt;TD&gt;$&quot; + pParking + &quot;&lt;/TD&gt;&lt;/TR&gt;&quot;);<br>&nbsp;&nbsp;&nbsp;DispWin.document.write(&quot;&lt;TR&gt;&lt;TD&gt;&lt;B&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/B&gt;&lt;/TD&gt;&lt;TD&gt;----------&quot; + &quot;&lt;/TD&gt;&lt;/TR&gt;&quot; );<br>&nbsp;&nbsp;&nbsp;DispWin.document.write(&quot;&lt;TR&gt;&lt;TD&gt;&lt;B&gt;Total: &lt;/B&gt;&lt;/TD&gt;&lt;TD&gt;&lt;B&gt;$&quot; + tTotal + &quot;&lt;/B&gt;&quot;);<br>&nbsp;&nbsp;&nbsp;DispWin.document.write(&quot;&lt;TR&gt;&lt;TD COLSPAN=2&gt;&quot; + pNotes );<br>&nbsp;&nbsp;&nbsp;DispWin.document.write(&quot;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&quot;);<br>}<br><br>&lt;/SCRIPT&gt;&lt;/HEAD&gt;<br>&lt;BODY BGCOLOR = &quot;#EEA600&quot;&gt;<br>&lt;H2&gt;Calculate your cost&lt;/H2&gt;<br>&lt;FONT FACE=&quot;Comic Sans&quot; SIZE=2 COLOR=&quot;#FF00GG&quot;&gt;<br>Click on the place to which you would like to<br>&lt;BR&gt;<br>go.&nbsp;&nbsp;Then click the number of people in each<br>&lt;BR&gt;<br>age group for your party.&nbsp;&nbsp;To get your total<br>&lt;BR&gt;<br>cost click the &quot;My Cost&quot; button.<br>&lt;/FONT&gt;<br>&lt;BR&gt;&lt;BR&gt;<br>Where would you like to go?<br>&lt;FORM NAME=&quot;formWhere&quot;&gt;<br>&lt;SELECT NAME=&quot;vWhere2&quot; SIZE=6 onChange=&quot;fWhere();&quot;&gt;<br>&lt;OPTION VALUE=-1 SELECTED&gt;&quot;Nowhere&quot;<br>&lt;OPTION VALUE=0&gt;&quot;Adler Planetarium&quot;<br>&lt;OPTION VALUE=1&gt;&quot;Brookfield Zoo&quot;<br>&lt;OPTION VALUE=2&gt;&quot;Field Museum&quot;<br>&lt;OPTION VALUE=4&gt;&quot;Sant's Village&quot;<br>&lt;OPTION VALUE=3&gt;&quot;Shedd Aquarium&quot;<br>&lt;/SELECT&gt;<br>&lt;INPUT TYPE=&quot;button&quot; VALUE=&quot;My Cost&quot;<br>onClick=&quot;Cost();&quot;&gt;<br>&lt;/FORM&gt;<br><br><br>&lt;FORM NAME=&quot;formPeople&quot;&gt;<br>Number of Adults?<br>&lt;SELECT NAME=&quot;vAdultNum&quot; SIZE=5 onChange=&quot;Adult();&quot;&gt;<br>&lt;OPTION VALUE=1 SELECTED&gt;&quot;One&quot;<br>&lt;OPTION VALUE=2&gt;&quot;Two&quot;<br>&lt;OPTION VALUE=3&gt;&quot;Three&quot;<br>&lt;OPTION VALUE=4&gt;&quot;Four&quot;<br>&lt;/SELECT&gt;<br><br>Number of Children?<br>&lt;SELECT NAME=&quot;vChildNum&quot; SIZE=5 onChange=&quot;Child();&quot;&gt;<br>&lt;OPTION VALUE=0 SELECTED&gt;&quot;None&quot;<br>&lt;OPTION VALUE=1&gt;&quot;One&quot;<br>&lt;OPTION VALUE=2&gt;&quot;Two&quot;<br>&lt;OPTION VALUE=3&gt;&quot;Three&quot;<br>&lt;OPTION VALUE=4&gt;&quot;Four&quot;<br>&lt;/SELECT&gt;<br><br>Number of Seniors?<br>&lt;SELECT NAME=&quot;vSeniorNum&quot; SIZE=5 onChange=&quot;Senior();&quot;&gt;<br>&lt;OPTION VALUE=0 SELECTED&gt;&quot;None&quot;<br>&lt;OPTION VALUE=1&gt;&quot;One&quot;<br>&lt;OPTION VALUE=2&gt;&quot;Two&quot;<br>&lt;OPTION VALUE=3&gt;&quot;Three&quot;<br>&lt;OPTION VALUE=4&gt;&quot;Four&quot;<br>&lt;/SELECT&gt;<br>&lt;/FORM&gt;<br><br>&lt;DIV ID=&quot;lyr_adler&quot; style=&quot;position:absolute; LEFT:325; TOP:15;<br>&nbsp;width:280; height:50; background-color:black;<br>&nbsp;visibility:hidden&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&lt;FONT FACE=&quot;Comic Sans&quot; SIZE=4 COLOR=&quot;#FFFFCC&quot;&gt;<br>&nbsp;&nbsp;&nbsp;Adler Planetarium<br>&nbsp;&nbsp;&nbsp;&lt;/FONT&gt;<br>&nbsp;&nbsp;&nbsp;&lt;/BR&gt;<br>&lt;A HREF = &quot;<A HREF=" TARGET="_new"> SRC=&quot;<A HREF=" TARGET="_new"> NO BORDER&gt;<br>&lt;/A&gt;<br>&lt;BR&gt;<br>&nbsp;&nbsp;&nbsp;&lt;FONT FACE=&quot;Comic Sans&quot; SIZE=2 COLOR=&quot;#FFFFCC&quot;&gt;<br>Click on the planet to go to the Adler Planetarium web page.<br>&lt;/FONT&gt;<br>&lt;/DIV&gt;<br><br>&lt;DIV ID=&quot;lyr_brookfield&quot; style=&quot;position:absolute; LEFT:325; TOP:15;<br>&nbsp;width:280; height:50; background-color:white; visibility:hidden&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&lt;FONT FACE=&quot;Comic Sans&quot; SIZE=4 COLOR=&quot;#000000&quot;&gt;<br>&nbsp;&nbsp;&nbsp;Brookfield Zoo<br>&nbsp;&nbsp;&nbsp;&lt;/FONT&gt;<br>&nbsp;&nbsp;&nbsp;&lt;/BR&gt;<br>&lt;A HREF = &quot;<A HREF=" TARGET="_new"> SRC=&quot;<A HREF=" TARGET="_new"> NO BORDER&gt;<br>&lt;/A&gt;<br>&lt;BR&gt;<br>&nbsp;&nbsp;&nbsp;&lt;FONT FACE=&quot;Comic Sans&quot; SIZE=2 COLOR=&quot;#000000&quot;&gt;<br>Click on the tiger to go to the Brookfield Zoo web page.<br>&lt;/FONT&gt;<br>&lt;/DIV&gt;<br><br>&lt;DIV ID=&quot;lyr_field&quot; style=&quot;position:absolute; LEFT:325; TOP:15;<br>&nbsp;width:280; height:50; visibility:hidden&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&lt;FONT FACE=&quot;Comic Sans&quot; SIZE=4 COLOR=&quot;#000000&quot;&gt;<br>&nbsp;&nbsp;&nbsp;Field Museum<br>&nbsp;&nbsp;&nbsp;&lt;/FONT&gt;<br>&nbsp;&nbsp;&nbsp;&lt;BR&gt;<br>&lt;A HREF = &quot;<A HREF=" TARGET="_new"> SRC=&quot;<A HREF=" TARGET="_new"> NO BORDER&gt;<br>&lt;/A&gt;<br>&lt;BR&gt;<br>&nbsp;&nbsp;&nbsp;&lt;FONT FACE=&quot;Comic Sans&quot; SIZE=2 COLOR=&quot;#000000&quot;&gt;<br>Click on the dinosaur to go to the Field Museum web page.<br>&lt;/FONT&gt;<br>&lt;/DIV&gt;<br><br>&lt;DIV ID=&quot;lyr_shedd&quot; style=&quot;position:absolute; LEFT:325; TOP:15;<br>&nbsp;width:280; height:50; visibility:hidden&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&lt;FONT FACE=&quot;Comic Sans&quot; SIZE=4 COLOR=&quot;#000000&quot;&gt;<br>&nbsp;&nbsp;&nbsp;Shedd Aquarium<br>&nbsp;&nbsp;&nbsp;&lt;/FONT&gt;<br>&nbsp;&nbsp;&nbsp;&lt;BR&gt;<br>&lt;A HREF = &quot;<A HREF=" TARGET="_new"> SRC=&quot;<A HREF=" TARGET="_new"> NO BORDER&gt;<br>&lt;/A&gt;<br>&lt;BR&gt;<br>&nbsp;&nbsp;&nbsp;&lt;FONT FACE=&quot;Comic Sans&quot; SIZE=2 COLOR=&quot;#000000&quot;&gt;<br>Click on the fish to go to the Shedd Aquarium web page.<br>&lt;/FONT&gt;<br>&lt;/DIV&gt;<br><br>&lt;DIV ID=&quot;lyr_santa&quot; style=&quot;position:absolute; LEFT:325; TOP:15;<br>&nbsp;width:280; height:50; visibility:hidden&quot;&gt;<br>&lt;A HREF = &quot;<A HREF=" TARGET="_new"> SRC=&quot;<A HREF=" TARGET="_new"> NO BORDER&gt;<br>&lt;/A&gt;<br>&lt;BR&gt;<br>&nbsp;&nbsp;&nbsp;&lt;FONT FACE=&quot;Comic Sans&quot; SIZE=4 COLOR=&quot;#000000&quot;&gt;<br>&nbsp;&nbsp;&nbsp;Santa's Village<br>&nbsp;&nbsp;&nbsp;&lt;/FONT&gt;<br>&nbsp;&nbsp;&nbsp;&lt;BR&gt;<br>&nbsp;&nbsp;&nbsp;&lt;FONT FACE=&quot;Comic Sans&quot; SIZE=2 COLOR=&quot;#000000&quot;&gt;<br>Click the Village logo to go to the Santa's Village web site.<br>&lt;/FONT&gt;<br>&lt;/DIV&gt;<br><br>&lt;/BODY&gt;<br>&lt;/HTML&gt; <p>bobbie<br><a href=mailto:thibault@hotbot.com>thibault@hotbot.com</a><br><a href= </a><br>
 
You're getting the famous 'adding two doubles' problem, where the output is more precise than the input (ok, so maybe the problem isn't famous, but I've seen it quite a bit). This is probably not a problem in your code (I'm sure enough that I'm not about to look through it)... rather, it's your processor. Well, not a <i>problem</i>, per se, just something that comes up pretty often (I've had to deal with it in Java, it's a pain).<br><br>Here's something you can do (and something you should do often in most of your programming when you get this kind of error)... whenever you perform any kind of arithmetic on a double where the result is a double, round off to the correct number of places. For example, in this case, always round off to the 2nd decimal place. I'm almost positive that that should work 100% of the time. <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top