Task2_Console

PHOTO EMBED

Mon May 01 2023 20:54:31 GMT+0000 (Coordinated Universal Time)

Saved by @Youssef_Taj

.data
prompt: .asciiz "Please enter your exam score: "
gradeA: .asciiz "Your grade is A.\n"
gradeB: .asciiz "Your grade is B.\n"
gradeC: .asciiz "Your grade is C.\n"
gradeD: .asciiz "Your grade is D.\n"
gradeF: .asciiz "Your grade is F.\n"
 
.text
.globl main
 
main:
    # Prompt the user for their exam score
    li $v0, 4
    la $a0, prompt
    syscall
    
    # Read in the score as an integer
    li $v0, 5
    syscall
    move $t0, $v0
    
    # Determine the grade based on the score
    bge $t0, 90, grade_a
    bge $t0, 80, grade_b
    bge $t0, 70, grade_c
    bge $t0, 60, grade_d
    j grade_f
    
grade_a:
    # Output "A" for scores >= 90
    li $v0, 4
    la $a0, gradeA
    syscall
    j exit
    
grade_b:
    # Output "B" for scores >= 80
    li $v0, 4
    la $a0, gradeB
    syscall
    j exit
    
grade_c:
    # Output "C" for scores >= 70
    li $v0, 4
    la $a0, gradeC
    syscall
    j exit
    
grade_d:
    # Output "D" for scores >= 60
    li $v0, 4
    la $a0, gradeD
    syscall
    j exit
    
grade_f:
    # Output "F" for scores < 60
    li $v0, 4
    la $a0, gradeF
    syscall
    
exit:
    # End the program
    li $v0, 10
    syscall
content_copyCOPY