Write a program that accepts astring from the user. You can assume the length of
ID: 3654882 • Letter: W
Question
Write a program that accepts astring from the user. You can assume the length of the string willbe less than 30 characters and only lower case letters areentered. Your program should then prompt the user to enter a letter (either lower case or upper case). Display the string with only upper case letters Display the length of the string Count the number of occurrences of the letter entered (upper or lower case), Store the string with the letter removed (upper and lower case occurrences) and display the shortened string Ask the user if they want to continue or not. Error checking on user input is required for the single letter input and the option to continue or not. Please enter in a string of a maximum of 30 letters: iloVeAssEmBlyLanguAge Please enter a letter: e The string in lower case is: iloveassemblylanguage The string in lower case is: ILOVEASSEMBLYLANGUAGE The length of the string is 21 characters The letter e appears 3 times The revised string is: ilovassmblylanguag Would you like to enter in another string (y/n)? n Good bye.Explanation / Answer
Here is my attempt it is not finished any help plz .section ".data" /*Variables*/ input: .word 0 yesNo: .byte 0 nl: .asciz " " prompt1: .asciz " Please enter in a string of a maximum of 30lower case letter:" prompt2: .asciz " Would you like to enter in a nnotherstring(y/n)?:" format1: .asciz "%d%c" format2: .asciz "%c%c" format3: .asciz " The sorted string is:" format4: .asciz " The strin is a palindrom:" format5: .asciz " The strin is not a palindrom:" format6: .asciz " Good bye:" format7: .asciz "%d" .align 8 .global main .section ".text" var(string,1,30*1) var(reverse,1,30*1) var(num,4) define(letter, l0) define(iter, l1) define(total, l2) define(rev_indx, l3) define(str_index, l4) main: save %sp, -96, %sp repeat: set prompt1,%o0 !ask fo a number call printf nop set format2,%o0 !input needs set input, %o1 !address where input is stored call scanf nop set input,%o1 !getting the array ldub [%fp+num],%total clr %str_index clr %iter loop: stb %o0, [%fp+string +%iter] add %o0, 1,%o0 add %iter, 1,%%iter cmp %iter,%total bl loop nop ld [fp +num],%total ! getting the revers array clr %rev_index mov %total,%str_index sub %str_index, 1,%str_index loop1: ldub [%fp + string+%str_index], %o0 stb %o0,[%fp + reverse +%rev_index] add %rev_iindex,1 , %rev_index sub %str_index,1 , %str_index cmp %rev_index , 1 ,%total bl loop nop !code go here set prompt2, %o0 call printf nop set format2,%o0 !getting a character and anewline set yesNo, %o1 set nl, %o2 call scanf nop set yesNo, %l0 ldub [%l0],%o0 !get the ys/no frommemory cmp %o0, 'y' be repeat nop !yes then try again ret !getout restore
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.