Marketplace
Related Articles
- Math Writing Prompts
- Best Writing Prompts
- Photograph Writing Prompts
- Fun Writing Prompts For Middle School
- Photo Prompts For Writing
- Picture Writing Prompts
- First Grade Writing Prompt
- Horror Writing Prompts
- Writing Prompts For High School Students
- Writing Prompt Ideas For Kids
- Short Story Writing Prompts For Middle School
- Descriptive Essay Writing Prompts
- Writing Prompts For Middle School
- Writing Prompts Teachers
- Daily Writing Prompts For High School
- Printable Writing Prompts
- Writing Prompts For 4th Grade
- Story Writing Picture Prompts
- Pass Writing Prompts
- Writing Prompts For Math
- Writing Prompts High School
- Short Story Writing Prompt
- 4th Grade Writing Prompts
- Activity Report Writing
- High School Creative Writing Prompts
- Step Up To Writing
- Writing Prompts Middle School
- Creative Writing Lesson Plans Middle School
- Creative Writing Prompts High School
- Creative Writing Ideas For Kids
- Writing For Dummies
- Youth Creative Writing
- Creative Writing Prompts For Adults
- Writing Prompts Middle School
- Ideas For Story Writing
- 5th Grade Writing Prompts
- Belonging Creative Writing Ideas
- Picture Prompts For Creative Writing For Kids
- Creative Writing Games For Kids
- How To Write A Creative Writing Piece
Related Categories
Recently Added
- English Writing Tips
- Picture Writing Prompts For First Grade
- How To Do A Resume
- Essay Writing Competitions 2010
- Essay Tips Writing
- How Write An Essay
- Writing Jobs In Philadelphia
- How To Learn English Grammar
- Freelance Writing Jobs Available
- Freelance Writing Job Openings
- Freelance Humor Writing Jobs
- How To Get A Job Writing Greeting Cards
- Seo Article Writing Jobs
- Blog Writing Jobs In India
- How To Get A Job Writing Jingles
- Writing Jobs London Uk
- Ebook Writing Jobs
- Home Based Writing Jobs In India
- Freelance Writing Job Search
- Nature Writing Jobs
Join StudyUp.com Today
You Recently Visited
Writing Prompts Fourth Grade
Lois Said:
Can someone help with this?We Answered:
You seem to be off on the wrong track there. The assignment specifies that you need to "use forms for collecting data from the user" and use form validation to verify user data. So your method of prompting isn't going to work. Here's some code that would work, but it comes with two caveats:1: It's not pretty. I haven't checked it. It might not work.
2: I've been doing this a long time, I'm a professional web developer with several years of experience and a computer science degree. So if you decide to submit my work as your own, then you should be prepared to explain how it actually works.
I suggest you use this as a model to help you answer the question yourself. Not as an answer itself. I'm really only doing this because it's fun for me. :-)
<html> <head> <title>Grades</title>
<script type="text/javascript">
function grade() {
var resultDiv = document.getElementById( "result");
resultDiv.innerHTML = "";
var grades = new Array();
var totalPoints = 0;
//create an array of grades and compute their total (out of 500 points):
for(var i=1; i<=5; i++) {
grades[i-1] = parseInt( document.getElementById('test' + i).value);
if(isNaN(grades[i-1]) || grades[i-1] < 0 || grades[i-1] > 100) {
alert('Sorry, Test ' + i + ' needs to contain a number from 0 to 100');
return;
}
totalPoints += grades[i-1];
}
var average = totalPoints / 5.0;
var letterGrade = new Array("F", "D", "C", "B", "A")[Math.min(4, Math.max( Math.floor((average - 50) / 10), 0))];
resultDiv.innerHTML = "You averaged " + average + " points, for an average letter grade of " + letterGrade;
}
</script>
</head>
<body>
<form>
Test 1: <input type="text" id="test1" name="test1" /><br/>
Test 2: <input type="text" id="test2" name="test2" /><br/>
Test 3: <input type="text" id="test3" name="test3" /><br/>
Test 4: <input type="text" id="test4" name="test4" /><br/>
Test 5: <input type="text" id="test5" name="test5" /><br/>
<input type="button" onclick="grade()" value="Get Results" /><br/>
</form><br/>
<div id="result"></div>
</body>
</html>
UPDATE: Fixed a bug that would cause 5 scores of 100 to return "undefined" as a letter grade...
Christy Said:
Javascript Help!!! Can someone Help!?We Answered:
// Here's a solution:// Use a loop for inputting the marks, and accumulate the sum at the same time:
// Number of scores 'n' can be easily changed by changing the value of n instead of editing program.
var i,mark,average,sum=0;
var n = 5;
for (i=1; i<=5; i++) {
mark = prompt("What was your score for test "+i+"?");
sum = sum + Number(mark);
}
Use a function to calculate the grade: using return 'grade letter' instead of a number of (cumbersome) else-ifs:
function getGrade(n) {
if (n>=90) : return "A";
if (n>=80) : return "B";
if (n>=70) : return "C";
if (n>=60) : return "D";
if (n>=50) : return "E";
return "U";
}
// do the calculations:
average= sum/n;
document.write ("Average mark = "+ average);
document.write(("Grade=" + getGrade (average);
Jason Said:
Javascript Help! Can someone finish this off?We Answered:
Something like this would be better:var letterGrade;
var testAverage = (Number(testScore) + Number(testScore2) + Number(testScore3) + Number(testScore4) + Number(testScore5)) / Number(5));
if (testAverage >= 90)
letterGrade = 'A';
else if (testAverage >=80)
letterGrade = 'B';
else if (testAverage >= 70)
letterGrade = 'C';
else if (testAverage >= 65)
letterGrade = 'D';
else
letterGrade = 'F';
document.write('This is the Average of all your Test Scores: ' + testAverage + '(' + letterGrade + ')');
If you need the letter grade for each score, then you can do it in a loop.