QUESTION TWO

a. Develop a QBASIC program to accept a student's index number, subject, and examination score out of 100.
b. Your program should match the score to the corresponding letter grade.
c. Save the program as `STGRADE` in the folder created.
d. Print the subject, index number, score, and grade on the computer screen. Save the output as `GRADES` in the folder created.
e. The grade letter is determined as follows:
\begin{tabular}{|l|l|l|l|l|l|l|}
\hline Exams score & 90 and above & [tex]$80-89$[/tex] & [tex]$70-79$[/tex] & [tex]$60-69$[/tex] & [tex]$50-59$[/tex] & Below 50 \\
\hline Assigned Grade & A & B & C & D & E & F \\
\hline
\end{tabular}



Answer :

Certainly! Let's tackle this step-by-step.

### Question Two

a. Develop a QBASIC program to accept student index number, subject, and examination score over 100.

Here is a QBASIC program snippet to achieve this:

```qbasic
INPUT "Enter student index number: ", student_index
INPUT "Enter subject name: ", subject
INPUT "Enter examination score: ", score
```

b. Your program should match the score to the letter.

We will implement logic to match the score to its corresponding grade:

```qbasic
IF score >= 90 THEN
grade = "A"
ELSEIF score >= 80 THEN
grade = "B"
ELSEIF score >= 70 THEN
grade = "C"
ELSEIF score >= 60 THEN
grade = "D"
ELSEIF score >= 50 THEN
grade = "E"
ELSE
grade = "F"
END IF
```

c. Save the program as `STGRAI.BAS` in the folder created.

In QBASIC, to save the program, you would typically go to the file menu and choose "Save As...", then navigate to your desired folder and save the file as `STGRAI.BAS`.

d. Print the subject, index number, score, and grade on the computer screen. Save the output as GRADES in the folder created.

Let's extend our QBASIC program to print the subject, index number, score, and grade, and then save this output as `GRADES`.

```qbasic
CLS
PRINT "Subject: "; subject
PRINT "Student Index Number: "; student_index
PRINT "Score: "; score
PRINT "Grade: "; grade

OPEN "GRADES.TXT" FOR OUTPUT AS #1
PRINT #1, "Subject: "; subject
PRINT #1, "Student Index Number: "; student_index
PRINT #1, "Score: "; score
PRINT #1, "Grade: "; grade
CLOSE #1
```

Here is the complete QBASIC program:

```qbasic
INPUT "Enter student index number: ", student_index
INPUT "Enter subject name: ", subject
INPUT "Enter examination score: ", score

IF score >= 90 THEN
grade = "A"
ELSEIF score >= 80 THEN
grade = "B"
ELSEIF score >= 70 THEN
grade = "C"
ELSEIF score >= 60 THEN
grade = "D"
ELSEIF score >= 50 THEN
grade = "E"
ELSE
grade = "F"
END IF

CLS
PRINT "Subject: "; subject
PRINT "Student Index Number: "; student_index
PRINT "Score: "; score
PRINT "Grade: "; grade

OPEN "GRADES.TXT" FOR OUTPUT AS #1
PRINT #1, "Subject: "; subject
PRINT #1, "Student Index Number: "; student_index
PRINT #1, "Score: "; score
PRINT #1, "Grade: "; grade
CLOSE #1
```

Running this program with the input:
- Student Index Number: `001`
- Subject: `Mathematics`
- Examination Score: `87`

Will result in the output:
- Subject: Mathematics
- Student Index Number: 001
- Score: 87
- Grade: B

This is because a score of 87 falls within the range of 80-89, thus the assigned grade is 'B'.