grades project by jessica lane & jordan barnes block b

12
Grades Project Grades Project By Jessica Lane & Jordan By Jessica Lane & Jordan Barnes Barnes Block B Block B

Upload: tobias-oneal

Post on 08-Jan-2018

213 views

Category:

Documents


0 download

DESCRIPTION

The 2 Methods Fillgrades() Fillgrades() dim u, i as integer u = ubound(grades) u = ubound(grades) for i = 0 to u for i = 0 to u listbox1.cell (i,1) = str(grades(i)) listbox1.cell (i,1) = str(grades(i)) next i next iFillstudents() dim u, i as integer dim u, i as integer u = ubound(students) u = ubound(students) for i = 0 to u for i = 0 to u listbox1.addrow students (i) listbox1.addrow students (i) next i next i The 2 methods use ubound and a loop Ubound says to continue through the loop until all of the array has been added. Listbox1.cell is used to add grades because grades is numbers Listbox1.addrow is used for students because students are words.

TRANSCRIPT

Page 1: Grades Project By Jessica Lane & Jordan Barnes Block B

Grades ProjectGrades Project

By Jessica Lane & Jordan By Jessica Lane & Jordan BarnesBarnesBlock BBlock B

Page 2: Grades Project By Jessica Lane & Jordan Barnes Block B

Fill ArraysFill Arrays listbox1.heading(0) = listbox1.heading(0) =

"Student Names""Student Names"listbox1.heading(1) = listbox1.heading(1) =

"Student Grades""Student Grades" students = array ("Rebakeh", students = array ("Rebakeh",

"Marge", "Kethry", "Marge", "Kethry", "Yelena", "Fred", "Ginger", "Yelena", "Fred", "Ginger", "Tarma", "Karine", "Tarma", "Karine", "Savannah", "Jesse")"Savannah", "Jesse")

grades = array (90.7, 88.8, grades = array (90.7, 88.8, 467.9, 345.6, 43.6, 234.6, 467.9, 345.6, 43.6, 234.6, 478.0, 789.23, 34.5, 45.3)478.0, 789.23, 34.5, 45.3)

fillstudents ()fillstudents () fillgrades ()fillgrades ()

Listbox1.heading gives a Listbox1.heading gives a title to the column title to the column designated by the number designated by the number in parentheses. This title is in parentheses. This title is the phrase in quotes.the phrase in quotes.

Students = array says that Students = array says that this array is named this array is named students and the names students and the names following are part of the following are part of the array.array.

Grades = array says that Grades = array says that this array is named grades this array is named grades and the numbers following and the numbers following are part of the array.are part of the array.

The 2 methods put the The 2 methods put the array into the listboxarray into the listbox

Page 3: Grades Project By Jessica Lane & Jordan Barnes Block B

The 2 MethodsThe 2 Methods Fillgrades()Fillgrades()dim u, i as integerdim u, i as integer u = ubound(grades)u = ubound(grades)

for i = 0 to ufor i = 0 to u listbox1.cell (i,1) = listbox1.cell (i,1) =

str(grades(i))str(grades(i)) next inext i

Fillstudents()Fillstudents() dim u, i as integer dim u, i as integer u = ubound(students)u = ubound(students) for i = 0 to ufor i = 0 to u listbox1.addrow students (i)listbox1.addrow students (i) next inext i

The 2 methods use ubound The 2 methods use ubound and a loopand a loop

Ubound says to continue Ubound says to continue through the loop until all through the loop until all of the array has been of the array has been added.added.

Listbox1.cell is used to Listbox1.cell is used to add grades because add grades because grades is numbersgrades is numbers

Listbox1.addrow is used Listbox1.addrow is used for students because for students because students are words.students are words.

Page 4: Grades Project By Jessica Lane & Jordan Barnes Block B

Another WayAnother Way Dim u,i as integerDim u,i as integer listbox1.heading(0) = "Student"listbox1.heading(0) = "Student" listbox1.heading(1) = " Grades"listbox1.heading(1) = " Grades" students = array (" Juliette", students = array (" Juliette",

"Brady", " Jadyn", " Sam", "Brady", " Jadyn", " Sam", "Morgan", "Darren", "Kristine", "Morgan", "Darren", "Kristine", "Stewie", "Tim")"Stewie", "Tim")

Grades = array ( 100.0 , 78.6 , Grades = array ( 100.0 , 78.6 , 100.0, 95.4 , 89.2 , 76.0 , 87.9 , 100.0, 95.4 , 89.2 , 76.0 , 87.9 , 97.0 , 96.0)97.0 , 96.0)

for i = 0 to ufor i = 0 to u listbox1.addrow students(i)listbox1.addrow students(i) u = ubound(grades)u = ubound(grades) next Inext I for i=0 to u for i=0 to u listbox1.cell (i, 1)= str(grades(i))listbox1.cell (i, 1)= str(grades(i)) next i next i

This does the same as the This does the same as the previous way except that previous way except that instead of using methods the instead of using methods the information that was in the information that was in the methods is simply in the methods is simply in the Open event.Open event.

Page 5: Grades Project By Jessica Lane & Jordan Barnes Block B

Change GradesChange Grades if listbox1.listindex >= 0 if listbox1.listindex >= 0

thenthen

grades.removelistbox1.lisgrades.removelistbox1.listindextindex

grades.insertlistbox1.listindgrades.insertlistbox1.listindex,valex,val(studentgrade.text)(studentgrade.text)

listbox1.cell(listbox1.listilistbox1.cell(listbox1.listindex,1) ndex,1) =str(Studentgrade.text)=str(Studentgrade.text)

end ifend if

This code is located This code is located under a pushbutton.under a pushbutton.

This first removes the This first removes the selected listindex. selected listindex. Then it inserts the Then it inserts the grade typed into an grade typed into an editfield. Here the editfield. Here the editfield is editfield is studentgrade.textstudentgrade.text

The grade is put into The grade is put into the selected cell.the selected cell.

Page 6: Grades Project By Jessica Lane & Jordan Barnes Block B

Find MinimumFind Minimum dim mingrade as doubledim mingrade as double dim i as integerdim i as integer dim j as integerdim j as integer dim u as integerdim u as integer u = ubound(grades) u = ubound(grades) mingrade = grades(0)mingrade = grades(0) for i = 0 to u for i = 0 to u if mingrade > grades(i) thenif mingrade > grades(i) then mingrade = grades(i)mingrade = grades(i) end ifend if next inext i tiny.text = str(mingrade)tiny.text = str(mingrade)

A loop and a conditional A loop and a conditional are used togather and are are used togather and are located in a pushbuttonlocated in a pushbutton

The loop will continue to The loop will continue to the end of the array the end of the array because of the ubound.because of the ubound.

When the loop runs it When the loop runs it compares two grades and compares two grades and the lower grade becomes the lower grade becomes the new mingrade. Each the new mingrade. Each time the loop runs 2 new time the loop runs 2 new numbers are compared.numbers are compared.

Then the number is put Then the number is put into an editfield. Here the into an editfield. Here the editfield is tiny.texteditfield is tiny.text

Page 7: Grades Project By Jessica Lane & Jordan Barnes Block B

Find MaximumFind Maximum dim highgrade as doubledim highgrade as double dim i as integerdim i as integer dim j as integerdim j as integer dim u as integerdim u as integer u = ubound(grades) u = ubound(grades) highgrade = grades(0)highgrade = grades(0) for i = 0 to ufor i = 0 to u if highgrade < grades(i) thenif highgrade < grades(i) then highgrade = grades(i)highgrade = grades(i) end ifend if next inext i giant.text = str(highgrade)giant.text = str(highgrade)

A loop and a conditional are A loop and a conditional are used togather and are used togather and are located in a pushbutton.located in a pushbutton.

The loop will continue to the The loop will continue to the end of the array because of end of the array because of the ubound.the ubound.

When the loop runs it When the loop runs it compares two grades and compares two grades and the higher grade becomes the higher grade becomes the new highgrade. Each the new highgrade. Each time the loop runs 2 new time the loop runs 2 new numbers are compared.numbers are compared.

Then the number is put into Then the number is put into an editfield. Here the an editfield. Here the editfield is giant.texteditfield is giant.text

This is located under a This is located under a pushbuttonpushbutton

Page 8: Grades Project By Jessica Lane & Jordan Barnes Block B

Find AverageFind Average dim u as integerdim u as integer dim k as integerdim k as integer dim result as doubledim result as double u = ubound(grades)u = ubound(grades) result = 0result = 0 for k = 0 to ufor k = 0 to u result =result + grades(k)result =result + grades(k) next knext k u = u +1u = u +1 average.text = str(result/u)average.text = str(result/u)

To find the average a loop To find the average a loop was used and ubound was was used and ubound was used in the loop.used in the loop.

The 1The 1stst grade would be grade would be added to the next and added to the next and become the result. This become the result. This would repeat until the end would repeat until the end of the array was reached.of the array was reached.

u = u+1 had to be added u = u+1 had to be added becase the rows start at 0 becase the rows start at 0 not at 1.not at 1.

The result divide by the The result divide by the number of grades in the number of grades in the array (represented by u) is array (represented by u) is imputed into the editfield imputed into the editfield (here is average.text).(here is average.text).

Page 9: Grades Project By Jessica Lane & Jordan Barnes Block B

Delete StudentDelete Studentlistbox1.removerow listbox1.removerow

listbox1.listindexlistbox1.listindex This removes the This removes the

selected row of the selected row of the listbox.listbox.

It is located under It is located under a pushbutton.a pushbutton.

Page 10: Grades Project By Jessica Lane & Jordan Barnes Block B

Add StudentAdd Student dim item as stringdim item as string dim soup as stringdim soup as string soup = studentgrade.textsoup = studentgrade.text item = studentname.textitem = studentname.text grades.append val(soup)grades.append val(soup) students.append "item"students.append "item" listbox1.addrow itemlistbox1.addrow item

listbox1.cell(listbox1.lastindelistbox1.cell(listbox1.lastindex,1) = soup x,1) = soup

2 editfields for grade and 2 editfields for grade and student name are set equal student name are set equal to soup and item to soup and item respectively.respectively.

The a new grade is added to The a new grade is added to the array using append. This the array using append. This grade is equal to the value grade is equal to the value of soup or what has been of soup or what has been typed into the editfield.typed into the editfield.

The a new student is added The a new student is added to the array using append. to the array using append. The student name is what The student name is what was typed in item.was typed in item.

Addrow and lastindex add Addrow and lastindex add the student and grade the student and grade respectively to the listbox.respectively to the listbox.

Page 11: Grades Project By Jessica Lane & Jordan Barnes Block B

Double-ClickDouble-Click studentname.text = studentname.text =

students(listbox1.listudents(listbox1.listindex)stindex)

studentgrade.text = studentgrade.text = str(grades(listbox1str(grades(listbox1.listindex)).listindex))

This code imputs This code imputs the listindex the listindex (grade and (grade and student) into student) into editfields with a editfields with a double-click of a double-click of a mouse.mouse.

Page 12: Grades Project By Jessica Lane & Jordan Barnes Block B

User InterfaceUser Interface On our User Interface the listbox was On our User Interface the listbox was

located on the left side of the window. located on the left side of the window. Each push button was located next to Each push button was located next to or under the editfield it corresponded or under the editfield it corresponded to. For example the button to find the to. For example the button to find the maximum was located directly under maximum was located directly under the editfield in which the maximum the editfield in which the maximum would appear. This was to make it would appear. This was to make it easier to read and use.easier to read and use.