Computer Science Visual Basics app.

profileFahad502
lab50.pdf


 1


Lab 5 CS 105 Fall 2014

Objectives:

1. Gain an understanding of how to implement and use functions. 2. Gain an understanding of scope. 3. Learn to use CheckBoxes. 4. Learn to format Double data type values as percentage. 5. Learn to write to file. 6. Learn to read from a file. 7. Learn to use message dialogs to display information to the user. 8. Learn to use the Visible property of objects on the form.

DUE DATES: Both Sections: TUESDAY 25 NOVEMBER

PROBLEM TO SOLVE:

During the quarter, CS105 students would like to know what grade they would receive based on all assignments and exams that have so far been submitted and graded. Design a program that permits the user to select which assignments and exams have been submitted, and to enter the scores received on these. The program should then display the grade based on these, as both a percentage value and a letter grade. After the grade has been calculated, write the information to file, and using a MessageBox, inform the user that the information has been written to file. Finally, allow the user to read the contents of the file that has been written.

The program must use CheckBoxes to allow the user to select which assignments and exams have been graded.

In order to get full credit on this project, you must implement the following two functions:

The program must implement a function procedure to return the numerical grade (i.e. percentage grade) based on the currently graded assignments and exams.

The program must also implement a function to convert the percentage grade to the corresponding letter grade.

Make a Lab5 folder in your CS account.

Create a new project and name it GradeCalculator. Save it inside the Lab5 folder. Rename the source code file GradeCalculator.vb. Rename the form GradeCalculatorForm

Here are a few hints to help you get started:

1. Pages 195 - 197 in your text provides information on how to implement and use functions.

2. Pages 169 - 170 in your text provides information on how to use the CheckBox control. Pay especial attention on how to utilize the Checked property of the CheckBox.


 2


3. Page 172 of your text describes how to use message dialogs. 4. Set to zero the default Text property of the TextBoxes used for user input. 5. If both the click event and a function require access to constants or variables,

these need to be declared with class scope. Pages 203 – 206 in your text explain the concept of scope.

6. Item #4 at the top of page 470 and the middle paragraph page 504 describe how to use the Visible property of a control on the form.

7. For the syntax required to write to file and read from file refer to the “Making sense of writing and reading files” document available on the Schedule page, along with the SimpleReadWrite example program located in the class folder.

8. To display the contents of the file, use a Multiline, ReadOnly TextBox, with the ScrollBars property set to Both.

9. The syntax for formatting a double value to a percentage is: numGradeTxt.Text = String.Format(“{0:P}”, numericalGrade) For example, if the value stored in numericalGrade is 0.9454, the following would be displayed in numGradeTxt: 94.54%

10. The following weighted values for each assignment can be found on the CS105 Syllabus web site.

11. Use the following grading scale cutoff values to convert the numerical grade to a letter grade.

A: 94.0%

A-: 90.0%

B+: 87.0%

B: 83.0%

B-: 80.0%


 3


C+: 77.0%

C: 73.0%

C-: 70.0%

D+: 67.0%

D: 63.0%

D-: 60.0%

F: < 60.0%

For example, a numerical grade of 94.0% would convert to an A; 93.9% would convert to an A-; 77.0% would be a C+, etc.

12. Study the Sample Output images below to understand the way to set up the form and the sequence of events that should be followed.

Sample Output:

Step 1: Select assignments and enter grades.


 4


Step 2: Click the Calculate Grade button to display cumulative grade of these assignments. Note that the Write Grades To File button is now visible.

Step 3: Click the Write Grades To File button, which generates a MessageBox to inform the user that information has been written to file. Click the OK button of the MessageBox.


 5


Step 4: Click the Read Grades From File button

Step 5: The contents of the file are displayed; both the Write Grade To File Button and the Read Grades From File button are now no longer visible.