/    Sign up×
Community /Pin to ProfileBookmark

Please Please Help Me!!!

im a senior in college and im having the hardest time in my web design class. when i tried to ask the teacher for help, she said “i have no idea what you’re talking about” and then walked away so she’s clearly NO HELP. she doesnt give partial credit on the homeworks OR quizes and im failing. I CANNOT figure out this homework assignment…

[B]Assignment #5 – 10 points

Write a script using JavaScript in an XHTML file that calculates and prints the sum of the integers from 20 to 50 (inclusive). This means you need to add 20 + 21 + 22 + 23… + 50. Use a counter-controlled while statement to loop through the calculation. Do not prompt the user for the numbers.

Include your name as the title of the web page. Submit a print out of your XHTML source code and a copy of the web page in IE 6.0 for grading. Staple all pages together before submitting them.[/B]

PLEASE HELP ME ?

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@mrhooFeb 22.2007 — The best help you can get is to fail this class. As a senior in college, you need one failure.

Failure is good- it permits the advance of the more able.

I especially like the part where you staple the pages together...

[CODE]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The dog processed my homework</title>
<meta name="author " content="Areoka and the Carpenter's Cat" />

<style type="text/css">
button{font-size:.8em;font-family:arial, sans-serif;font-weight:600;
padding:0 2px;color:#191970;background-color:#cdcdcd;cursor:pointer;}
button:focus,button:hover{color:red}
li{font-size:1em}
ul(margin:1em}
#footer{clear:both;position:relative;text-align:center;margin-bottom:10px}
</style>
<script type="text/javascript">
onload=function(){
var count=20, sum=20, str='20', el;
var who=document.getElementsByTagName('span');
var pa=document.getElementsByTagName('ul')[0];

while (50>count){
sum+= ++count;
str+='+'+count+'('+sum+') ';
if(count%4== 0){
el= document.createElement('li')
el.appendChild(document.createTextNode(str));
pa.appendChild(el);
str='';
}
}
el= document.createElement('li')
el.appendChild(document.createTextNode(str));
pa.appendChild(el);

who[1].lastChild.data=sum;
who[1].parentNode.removeChild(who[0]);

document.getElementsByTagName('button')[0].onclick=function(){
var who=document.getElementsByTagName('div')[0];
var dis= who.style.visibility.toLowerCase();
if(dis !='visible') who.style.visibility= 'visible';
else who.style.visibility='hidden';
}
}

</script>
</head>

<body>

<h1>The sum of the integers from 20 to 50 (inclusive) is <span>not</span><span>20</span></h1>
<h2><button type="button">Proof</button></h2>
<div style="visibility:hidden">
<ul>
<li> Proof</li>
</ul>
</div>
<div id="footer">
<p>
<a href="http://validator.w3.org/">
<img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a></p>
</div>
</body>
</html>[/CODE]
Copy linkTweet thisAlerts:
@maiku_no_jutsuFeb 22.2007 — I'd be careful about using the code he gave you in that last post. It is alot and very complicated to get the same result as the code I am providing you. 99% of that code in their you probably haven't even seen since you are a senior in college and doing something so simple as a while() statement to add some numbers. Your web class must not be very important to your major/minor if you are a senior and something so simple is being asked of you.

So, here is the code, and if I were you, I'd use this instead. It seems to me this is all the teacher is asking for and should be plenty as it gives the result asked for without all that extra unneeded stuff that other guy put in his post.

Just don't forget to put your name in the Title tags.

<i>
</i>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Your Name Here&lt;/title&gt;

&lt;script type="text/javascript"&gt;
function inclusive() {
var counter = 20;
var value = 0;
while (counter &lt; 51) {
value = counter + value;
counter++;
}
return value;
}
&lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;
The sum of the integers 20 to 50 (inclusive) is:
&lt;script type="text/javascript"&gt;
sum = inclusive();
document.write(sum);
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@mrhooFeb 22.2007 — [B]while (counter < 51) {[/B] will fail validation in xhtml strict

The longer page offered passes... I would say the whole point of this exercize is that one less than symbol.
Copy linkTweet thisAlerts:
@maiku_no_jutsuFeb 22.2007 — hmm...ok..sorry im not 100% familiar with xhtml...so..why exactly wud it fail...it's javascript. its in script tags. it should have nothing to do with the xhtml right? why would xhtml look at js code?
Copy linkTweet thisAlerts:
@maiku_no_jutsuFeb 22.2007 — and just for the record..i meant all the CSS stuff you wrote that's what i was calling extra....

for all we know this person hasn't learned CSS, and for them to put all that stuff in there, might be counterproductive. all the teacher asked for was javascript and xhtml. usually that means they want it with the least amount of code and the shortest way possible with only javascript and xhtml. mebbe if she through all that css, the teacher might wonder what's going on.
Copy linkTweet thisAlerts:
@mrhooFeb 22.2007 — You have to figure that a senior level class that specifies 'xhtml' is going to be about valid xhtml. You cannot include literal less than '<' or ampersands '&' in the text of xhtml elements.

Since most people write whiles as 'while something is [B]less than [/B]a limit, it seems that the professor is pulling a fast one. The only way to include the '<' in valid xhtml is to put it in a CData comment- and that's probably lesson 6.
Copy linkTweet thisAlerts:
@maiku_no_jutsuFeb 22.2007 — Ok, I fixed it with the validator. Sory, I'm not trying to be stupid with you mrhoo. I was jsut curious. But I really think all that extra coding other than the simple while statement and the xhtml requested is a possible red flag for the teacher if the student is not suppsoed to know that stuff. Also, many teachers only want what was asked for and CSS was not in the requirements. So in honesty (since this code I have is xhtml validated now, and meets the code requirements with the least amount of code possible, it might be wiser for hockeyangel to use this code.


<i>
</i>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;

&lt;head&gt;
&lt;title&gt;Your Name Here&lt;/title&gt;

&lt;script type="text/javascript"&gt;
function inclusive() {
var counter = 20;
var value = 0;
while (51 &gt; counter) {
value = counter + value;
counter++;
}
return value;
}
&lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;
&lt;p&gt;
The sum of the integers 20 to 50 (inclusive) is:
&lt;script type="text/javascript"&gt;
sum = inclusive();
document.write(sum);
&lt;/script&gt;
&lt;/p&gt;

&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@hockeyangelauthorFeb 22.2007 — OMG THANK YOU THANK YOU THANK YOU. actually, that last one is EXACTLY right. it is a beginners course in web design and no, it doesnt have anything to do w/ my major. it was just a business elective that fit the time slot i needed so i took the class. and i CANNOT fail this class or else I wont graduate in April like Im supposed to. Im 2 months away from being DONE WITH SCHOOL!!! so you can imagine my frustration b/c im failing the class and i simply just dont get it. i wish this stuff came natrually to me, but for some reason it goes right over my head. thank you again. this really helped. i'll probably be back again trying to get help w/ the next homework lol. THANK YOU!!!!!
×

Success!

Help @hockeyangel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...