Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic (http://www.programmingforums.org/forum18.html)
-   -   Question on a Homework extra credit. (http://www.programmingforums.org/showthread.php?t=14695)

Direth Dec 5th, 2007 1:20 PM

Question on a Homework extra credit.
 
So i'm in a CS1 Class(Beginners to CS Class) and its almost through, well So my teacher gives us all a question for extra credit to point us in the direction of where we want to go in life... This is the question and the tags, im not very code literate so ill post part of it.

----
:

<html>
<head>
<title>
CS1: Assignment 6 - Javascript  Programming - YOUR NAME HERE
</title>
<script type="text/javascript">
        function calculate(){
                        var num1 = 0, num2 = 0, num3 = 0, result = 0;
                       
                // INPUT:
                // retrieve the three values the user entered
                //  and store them in the variables num1, num2 and num3
                                num1 = parseInt(document.mytable.first.value);
                                num2 = parseInt(document.mytable.second.value);
                                num3 = parseInt(document.mytable.third.value);
     
                // CALCULATIONS (MODIFY THIS PART)
                                //  alter this program so that it calculates the
                                //  greatest of the three inputs
-----                                //  instead of the sum of the three inputs
((This is where i got stuck and this is the code part i implimented..

If (num1 > num2)
then (result = num1)
else(result=num2);

If(num2>num3)
then(result = num2)
else(result = num3);

If(num1>num3)
then(result=num1)
else(result=num3)
---
            // OUTPUT:
                // write the result variable to the screen
                document .mytable.result.value = result;
        }
</script>
</head>
<body>
<h3>Sum of three numbers by YOUR NAME HERE</h3>
<form name="mytable" action="">
<table border="1">
<tr><td>number one</td><td>
<input name="first" type="text" />
</td></tr>
<tr><td>number two</td><td>

<input name="second" type="text" />
</td></tr>
<tr><td>number three</td><td>
<input name="third" type="text" />
</td></tr>
<tr><td>result</td><td>
<input name="result" type="text" onfocus="blur()"/>
</td></tr>
<tr><td colspan="2">
<input type="button" value="Go!" onclick="calculate()" />
</td></tr>
</table></form>
</body>
</html>

---------
So we had a teachers aid help us, and she wasnt able to help much. She told us this is advanced work for a beginners class. So any help on what i should do?
Oh yeh, we have to make the table show which of the 3 inputs registers the highest value than the other 2.

Arla Dec 5th, 2007 2:54 PM

Re: Question on a Homework extra credit.
 
First off, figure out the logic.
I'm not 100% sure I understand what your output is actually supposed to be but,

How do you find the highest of three numbers, write (on paper) some pseudo logic, and then go through it by hand with three numbers, do it again with three different numbers.

lectricpharaoh Dec 5th, 2007 3:20 PM

Re: Question on a Homework extra credit.
 
Why's this in the VB forum, when there's already a forum where it should be?


All times are GMT -5. The time now is 3:40 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC