/    Sign up×
Community /Pin to ProfileBookmark

Beginner Script problem for class

I need to design a program that averages 3 input values by a prompt system, and displays the message good job you got a 94 or above and so on. I Know I did something wrong because this thing wont execute. Can someone take a look and help a bro out!

<html>
<body>
<script>
Var average1, average2, average3, total;
average1= prompt(“Write number” “”);
average2= prompt(“Write number” “”);
average3= prompt(“Write number” “”);
total= ((average1+average2+average3)/2);
alert(“total”);
If (total>=94) {
alert(“good job you got an A!”)
}
else if(94>total>=84){
alert(“You got a B.”)
}
}
else if(84>total>=70){
alert(“You got a C.”)
}
}
else if(70>total>=60){
alert(“You got a D.”)
}
}
else if(70>total>=60){
alert(“You got an F.”)
}
</script>
</body>
</html>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@pactor21Oct 25.2011 — There are a couple of mistakes I saw. First below is the working js code.
[CODE]var average1, average2, average3, total;
average1 = prompt("Write number"[COLOR="Red"],[/COLOR]"");
average2 = prompt("Write number"[COLOR="red"],[/COLOR]"");
average3 = prompt("Write number"[COLOR="red"],[/COLOR]"");
total = ((average1 + average2 + average3) / [COLOR="red"]3[/COLOR]);
alert(total);
if(total >= 94) {
alert("good job you got an A!")[COLOR="red"];[/COLOR]
}
else if (94 > total >= 84) {
alert("You got a B.")[COLOR="red"];[/COLOR]
}
else if (84 > total >= 70) {
alert("You got a C.")[COLOR="red"];[/COLOR]
}
else if (70 > total >= 60) {
alert("You got a D.")[COLOR="red"];[/COLOR]
}
else if (70 > total >= 60) {
alert("You got an F.")[COLOR="red"];[/COLOR]
}[/CODE]


I marked red where I had to make the code work properly. Besides those, you had brackets all wrong. Always match opening and closing parentheses.
Copy linkTweet thisAlerts:
@tomm12authorOct 25.2011 — Thank you, those brackets killed me!
×

Success!

Help @tomm12 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...