Well my homework is due 2 days from now and the professor only discussed with us a very little topic about arrays.
We were asked to make a pseudo code that would ask for a Student's Quiz scores from 1-4, Learning Task scores from 1-4 and a Final exam grade.
I understand that the size of my array is 9. Size = 9
What i don't know how to do is...YES! I don't know how to use arrays. Our professor told us that we can apply array when the user inputs the student's scores and store it up in a array. I am really lost.
Can anyone explain me how i can find a way around this?
Thanks so much !
8 Replies - 21029 Views - Last Post: 20 September 2011 - 05:00 AM
#1
Help with Array ( Simple one tho ) just need a guide
Posted 15 September 2011 - 05:34 AM
Replies To: Help with Array ( Simple one tho ) just need a guide
#2
Re: Help with Array ( Simple one tho ) just need a guide
Posted 15 September 2011 - 05:38 AM
basic info on arrays (of interest are the chapters "Description" (top) and "Examples" (bottom))
#3
Re: Help with Array ( Simple one tho ) just need a guide
Posted 15 September 2011 - 05:52 AM
Well im still having a hard time to understand,
but i really appreciate the help sir!.
The problem that i have is this...how exactly can i use array so that it can store a value that i input?
then can be called by a command afterwards?
but i really appreciate the help sir!.
The problem that i have is this...how exactly can i use array so that it can store a value that i input?
then can be called by a command afterwards?
This post has been edited by kong04601: 15 September 2011 - 05:55 AM
#4
Re: Help with Array ( Simple one tho ) just need a guide
Posted 15 September 2011 - 05:54 AM
You might find this array tutorial helpful. Although it refers specifically to C++ the explanation is general enough so that shouldn't matter.
#5
Re: Help with Array ( Simple one tho ) just need a guide
Posted 15 September 2011 - 06:01 AM
thanks i'm really trying hard to get all these as much as i can...but can anyone please help me with a simple example?
I really can't find an example in the net so i can better understand on how array can store an inputted data and then be called afterwards.
I really am sorry for pestering because i really am panicking.
I really can't find an example in the net so i can better understand on how array can store an inputted data and then be called afterwards.
I really am sorry for pestering because i really am panicking.
#6
Re: Help with Array ( Simple one tho ) just need a guide
Posted 15 September 2011 - 06:10 AM
The C++ tutorial gives simple examples.
Relating it to your assignment, you can use the array essentially the same as you would use ordinary variables but instead of storing the first value in a variable called QuizScore1, you can store it in ScoreArray[0]. The second one, instead of QuizScore2, can go in ScoreArray[1]. And so on ...
Relating it to your assignment, you can use the array essentially the same as you would use ordinary variables but instead of storing the first value in a variable called QuizScore1, you can store it in ScoreArray[0]. The second one, instead of QuizScore2, can go in ScoreArray[1]. And so on ...
#7
Re: Help with Array ( Simple one tho ) just need a guide
Posted 15 September 2011 - 06:17 AM
Thanks!
I have made a rough draft on how i understood the examples...
Could you please kindly check if i got it right?
I basically want here the array to store a value that i want.
Element count would be the number of tests the student have and input the grade afterwards.
I have made a rough draft on how i understood the examples...
start
declare variables
string elementCnt
string newMember
num testTotal = 0
num i = 0
num grades[]
display "Enter the number of Tests"
input elementCnt
for i = 0 to (elementCnt - 1)
grades[i] = 0
display "Enter Score: "
input grades [i]
testTotal = testTotal + grades [i]
i equals 0
for i = 0 to (elementCnt - 1)
print "Test Score " plus i plus " equals " plus grades [i]
print "Total >> " plus testTotal
print "Average >> " plus (testTotal / elementCnt)
end
Could you please kindly check if i got it right?
I basically want here the array to store a value that i want.
Element count would be the number of tests the student have and input the grade afterwards.
#8
Re: Help with Array ( Simple one tho ) just need a guide
Posted 15 September 2011 - 06:35 AM
as a rough design, it is ok. the real task is to put that into JS code.
some annotations though:
- user input: never trust user input, if you expect a number, test whether it is one (e.g. parseInt() & isNaN())
- x = x + y => x += y
- output: use Element.innerHTML or InputElement.value:
advanced option: experts are able to make an array calculate the average itself. for example:
some annotations though:
- user input: never trust user input, if you expect a number, test whether it is one (e.g. parseInt() & isNaN())
- x = x + y => x += y
- output: use Element.innerHTML or InputElement.value:
// for elements like <div> and <span>
document.getElementById("id").innerHTML = text;
// for text boxes <inut type="text">
document.getElementById("id").value = text;
advanced option: experts are able to make an array calculate the average itself. for example:
// do some JS magic
Array.prototype.average = function()
{
var sum = 0;
for (var i = this.length; i--;)/> {
if (typeof this[i] == "number") {
sum += this[i];
}
}
return (sum / this.length);
};
// create an array
var arr = [1,2,4,6,3,7,9,4,6,8];
// alert average value
alert(arr.average()); // 5
// more magic:
// minimum value
alert(Math.min.apply(Math, arr));
// maximum value
alert(Math.max.apply(Math, arr));
This post has been edited by Dormilich: 15 September 2011 - 06:49 AM
#9
Re: Help with Array ( Simple one tho ) just need a guide
Posted 20 September 2011 - 05:00 AM
Thanks for all the help!
MY prof accepted my code and so i will be sharing it in case someone needs the code.
MY prof accepted my code and so i will be sharing it in case someone needs the code.
start Declarations string studentName string studentSection num studentNumber string HEADER1 = "CLASS RECORD"; string HEADER2 = "Student Num. Name Section Remarks" num q = 1 num lt = 1 num fe num totalQuiz num totalLT num finalExam num finalGrade num grades[q] num learningTask[lt] housekeeping() while studentNumber <> 0000 detailLoop() endwhile endofjob() stop housekeeping() display HEADER1 display HEADER2 input studentNumber return detailLoop() display "Input Student's Name and Section" input studentName,studentSection while q < 5 display "Enter Quiz Scores 1-4 : " input grades[q] q = q+1 endwhile while lt < 5 display "Enter LT Scores 1-4 : " input learningTask[lt] lt = lt+1 endwhile display "Enter Final Exam Score : " input fe totalquiz = ((grades[1]/50)*Percentage) + ((grades[2]/50)*Percentage) + ((grades[3]/50)*Percentage) + ((grades[4]/50)*Percentage) totalLT = ((learningTask[1]/50)*Percentage) + ((learningTask[2]/50)*Percentage) + ((learningTask[3]/50)*Percentage) + ((learningTask[4]/50)*Percentage) totalFE = (fe/100)*Percentage finalGrade = totalquiz + totalLT + totalFE display studentNumber,studentName,studentSection,"Final Grade:",finalGrade if finalGrade < 70 then output "Failed" else output "Passed" endif input studentNumber return endofJob() display "End of Report" return
Page 1 of 1

New Topic/Question
Reply


MultiQuote


|