Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is my program that gets number of credits as integer and store them in $t2

ID: 3538978 • Letter: T

Question

This is my program that gets number of credits as integer and store them in $t2 and get quality points and store them as inetger in $t3 then should show the GPA in 2 decimals by dividing number of credits by quality points

the program get number of credits and quality points as long as there is not a negative number

.text


main:

# ...................................................... First Question

la $a0,text1

li $v0,4

syscall #............................................... Print String

li $v0,5   

syscall # .............................................. Read Integer

move $t0,$v0

# ...................................................... Checking The Input

blez $t0,after_loop

add $t2,$t2,$t0 #....................................... Summing up Number of Credits

# ...................................................... Second Question

la $a0,text2

li $v0,4

syscall # .............................................. Print String

li $v0,5   

syscall # .............................................. Read Integer   

move $t1,$v0

# ...................................................... Checking The Input

blez $t1,after_loop

add $t3,$t3,$t0 # ...................................... Summing up Quality points

j main # ............................................. looping to the begining


add $t0,$zero,$zero

add $t1,$zero,$zero



after_loop:

la $a0,text6

li $v0,4

syscall # .............................................. Print String

li $v0,5

syscall

li $t0,0

li $t1,1

bne $v0,$t1,no

bne $v0,$t0,yes

j after_loop



yes:





no:


mtc1 $t2, $f0

cvt.s.w $f0, $f0


mtc1 $t3, $f1

cvt.s.w $f1, $f1


la $a0,text3

li $v0,4

syscall


div.d $f0,$f0,$f1

add.d $f12,$f12,$f0

li $v0,2

syscall










done:

li $v0,10

syscall


# ....................................................................................

.data

text1: .asciiz "Please Enter Number Of Credits In Integer (Negative To Quit) : "

text2: .asciiz "Please Enter Number Of Quality Points In Integer(Negative To Quit) : "

text3: .asciiz "Your GPA Is : "

text4: .asciiz "You Have Enough Credit To Graduate :)"

text5: .asciiz "You Don't Have Enought Credit To Graduate :("

text6: .asciiz "Do you Want To Know Whether You Have Enough Credit To Graduate (yes:0 ~ no:1) : "

text7: .asciiz "Your Answer : "

input: .space 4




##############################################

I'm wondering can someone complete it so it shows the GPA in two decimal and if numebr of credits are less than 120 then shows text5 and if over 120 then shows text4


so far I get error, please help

Please help !!!

Explanation / Answer

please rate -thanks

spent hours but got it



.text
main:
li $t2,0          #initialize accumulators
li $t3,0
loop:
# ...................................................... First Question
la $a0,text1
li $v0,4
syscall #............................................... Print String
li $v0,5    
syscall # .............................................. Read Integer           
move    $t0,$v0
# ...................................................... Checking The Input
blez $t0,after_loop
add $t2,$t2,$t0 #....................................... Summing up Number of Credits
# ...................................................... Second Question
la $a0,text2
li $v0,4
syscall # .............................................. Print String
li    $v0,5    
syscall # .............................................. Read Integer            
move    $t1,$v0
# ...................................................... Checking The Input
blez $t1,after_loop
add $t3,$t3,$t1 # ...................................... Summing up Quality points
j loop # ............................................. looping to the begining
after_loop:
la $a0,text6
li $v0,4
syscall # .............................................. Print String
li $v0,5
syscall
li $t0,0
li $t1,1
bne $v0,$t0,no
bne $v0,$t1,yes
j after_loop
yes:
li $t0,120
blt $t2,$t0,notEnough
la $a0,text4
li $v0,4
syscall # .............................................. Print String
j no
notEnough:
la $a0,text5
li $v0,4
syscall # .............................................. Print String
no:
mtc1    $t2, $f0               #credits
cvt.s.w $f0, $f0
mtc1    $t3, $f1              #quality points
cvt.s.w $f1, $f1
div.s $f12,$f1,$f0
la $a0,text3
li $v0,4
syscall
li $t5,100                           
mtc1 $t5,$f5                      
cvt.s.w $f5,$f5  
mul.s $f12,$f12,$f5       #multiply by 100
cvt.w.s $f12,$f12
mfc1 $t4,$f12               #put it into register to round it
li $t1,100
div $t4,$t1
mflo $a0
li $v0,1
syscall
li $v0,4
la $a0,dot;
syscall
mfhi $a0
li $v0,1
syscall
done:
li $v0,10
syscall
# ....................................................................................
.data
text1: .asciiz "Please Enter Number Of Credits In Integer (Negative To Quit) : "
text2: .asciiz "Please Enter Number Of Quality Points In Integer(Negative To Quit) : "
text3: .asciiz "Your GPA Is : "
text4: .asciiz "You Have Enough Credit To Graduate :) "
text5: .asciiz "You Don't Have Enought Credit To Graduate :( "
text6: .asciiz "Do you Want To Know Whether You Have Enough Credit To Graduate (yes:0 ~ no:1) : "
text7: .asciiz "Your Answer : "
input: .space 4
dot: .asciiz "."
##############################################





Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote