![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Dec 2007
Posts: 1
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Mar 2005
Posts: 142
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#3 |
|
Caffeinated Neural Net
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 895
Rep Power: 4
![]() |
Re: Question on a Homework extra credit.
Why's this in the VB forum, when there's already a forum where it should be?
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| quick assembly question | jbo423 | Assembly | 4 | Nov 12th, 2007 7:21 AM |
| Multiplayer Game Question | Duck | Existing Project Development | 7 | Jan 2nd, 2007 12:19 PM |
| How to post a question | nnxion | C++ | 10 | Jun 3rd, 2005 11:53 AM |
| How to post a question | nnxion | C++ | 0 | Jun 3rd, 2005 8:55 AM |
| How to post a question | nnxion | C | 0 | Jun 3rd, 2005 8:55 AM |