in BASIC PROGRAMMING LANGUAGE heres is the question: e. Your program will mainta
ID: 3786799 • Letter: I
Question
in BASIC PROGRAMMING LANGUAGE heres is the question:
e. Your program will maintain the student information such as names, Id’s, and the exam1 score, exam2 score and exam3 score.
I cannot get the calculate(size) function to calculate average of entry except the first. how can i get this function to calculate avergage based on ID entered?here is my code so far:
size =1
Dim Name$(size)
Dim ID(size)
Dim Score1(size)
Dim Score2(size)
Dim Score3(size)
do
print "Enter your choice from this menu."
print "Enter 'P' to enter you information,OR"
print "Enter 'U' to update student information. OR,"
print "Enter 'C' to calculate average. OR,"
print "Enter 'D' to display student information. OR,"
print "Enter 'E' to exit."
input choice$
select case (choice$)
case "P","p"
res= collectData(size)
case "D","d"
res = display(size)
case "U","u"
res = update(size)
case "C","c"
res = calculate(size)
case "E","e"
print "Have a nice day.Goodbye."
case else
print "Invalid choice, please try again"
print
end select
loop until (choice$ = "E" or choice$ = "e" )
function collectData(size)
for position= 0 to size
print "Enter student name."
input Name$(position)
print "Enter student ID."
input ID(position)
print "Enter score 1 here."
input Score1(position)
print "Enter score 2 here."
input Score2(position)
print "Enter score 3 here."
input Score3(position)
next
end function
function display(size)
print "Enter student ID"
input studentinfo
for position = 0 to size
if(studentinfo = ID(position))then
print "student name is: ";Name$(position)
print "student ID is: ";ID(position)
print "student score 1 is: ";Score1(position)
print "student score 2 is: ";Score2(position)
print "student score 3 is: ";Score3(position)
exit for
end if
next
end function
function update(size)
print "Enter student ID"
input studentID
print "student name is: ";Name$(position)
print "student ID is: ";ID(position)
print "Enter score 1 here."
input Score1(position)
print "Enter score 2 here."
input Score2(position)
print "Enter score 3 here."
input Score3(position)
print "student score 1 is: ";Score1(position)
print "student score 2 is: ";Score2(position)
print "student score 3 is: ";Score3(position)
end function
function calculate(size)
print "Enter student ID"
input studentinfo
studentinfo = ID(size)
sum =( Score1(position) + Score2(position) +Score3(position)) /3
print "Your average is: ";sum
end function
Explanation / Answer
There are only 2 ways to make it possible.
1) create a structure with data items Name,ID,SCORE1,SCORE2,SCORE3 and then you can use them
2) Use Object oriented programming language ; and use object name as the id and then you can link that thing with the data
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.