Write a program using M.I.P.S that asks user “how many positive number that is devisable by 6 you want to add?” .Then your loopcounter would be the user input. If the user enters a positive number between 1 and 100 that is devisable by 6, you increment your loop counter and add it to the sum.. You need to decide if the positive number entered by the user is divisible by 6 or not. Your program should print an error message if the number is not within the range and ask user for another number. Make sure it works for when user types 0 and a negative number as well like sample output below.
An Example of sample input and output would be:
==============================================
How many positive number that is devisable by you want to add? 3
Enter a number: 36 ==> 36 is divisible by 6
Enter a number: -20
==> **** ERROR: -20 is not a positive number. Enter another
number.
Enter a number: 0
==> **** ERROR: 0 is not in the range of 1 to 100. Enter another
number.
Enter a number: 21
==> 21 is not divisible by 6. Enter another number.
Enter a number: 121 ==> **** ERROR: 121 is not in the range of 1 to 100. Enter another number.
Enter a number: 6 ==> 6 is divisible by 6
Enter a number: 12 ==> 12 is divisible by 6
The Sum of the positive numbers between 1 and 100 that are devisable by 6, is: 54 ===============================================
data
Prompt: .asciiz "How many positive number that is devisable by you
want to add? "
Prompt1: .asciiz "Enter a number: "
NewLine: .asciiz "\n"
Error: .asciiz "**Error: "
Success: .asciiz " is divisible by 6"
Fail: .asciiz " is not divisible by 6"
RestMessage: .asciiz " is not in the range of 1 to 100."
RestMessage1: .asciiz " is not a positive number"
Result: .asciiz "The Sum of the positive numbers between 1 and 100
that are devisable by 6, is: "
.text
Main:
addi $t6, $zero, 6
la $a0, Prompt
addi $v0, $zero, 4
syscall
addi $v0, $zero, 5
syscall
jal PrintNewLine
move $s0, $v0
addi $s1, $zero, 0
Loop:
la $a0, Prompt1
addi $v0, $zero, 4
syscall
addi $v0, $zero, 5
syscall
move $t0, $v0
blt $t0, 0, Lt
bgt $t0, 100, Gt
Else: div $t0, $t6
mfhi $t1
bne $t1, 0, No
Yes: add $s1, $s1, $t0
add $s0, $s0, 1
move $a2, $t0
jal PrintSuccess
jal PrintNewLine
b End
No: move $a2, $t0
jal PrintFail
jal PrintNewLine
End:
b Here
Lt: move $a2, $t0
la $a3, RestMessage1
jal PrintError
jal PrintNewLine
b Here
Gt: move $a2, $t0
la $a3, RestMessage
jal PrintError
jal PrintNewLine
Here:
addi $s0, $s0, -1
bne $s0, 0, Loop
la $a0, Result
addi $v0, $zero, 4
syscall
move $a0, $s1
addi $v0, $zero, 1
syscall
addi $v0, $zero, 10
syscall
PrintError: la $a0, Error
addi $v0, $zero, 4
syscall
move $a0, $a2
addi $v0, $zero, 1
syscall
move $a0, $a3
addi $v0, $zero, 4
syscall
jr $ra
PrintSuccess: move $a0, $a2
addi $v0, $zero, 1
syscall
la $a0, Success
addi $v0, $zero, 4
syscall
jr $ra
PrintFail: move $a0, $a2
addi $v0, $zero, 1
syscall
la $a0, Fail
addi $v0, $zero, 4
syscall
jr $ra
PrintNewLine: la $a0, NewLine
addi $v0, $zero, 4
syscall
jr $ra
\color{red}\underline{Output:}
How many positive number that is devisable by you want to add? 3
Enter a number: 36
36 is divisible by 6
Enter a number: -12
**Error: -12 is not a positive number
Enter a number: 123
**Error: 123 is not in the range of 1 to 100.
Enter a number: 12
12 is divisible by 6
Enter a number: 15
15 is not divisible by 6
Enter a number: 13
13 is not divisible by 6
The Sum of the positive numbers between 1 and 100 that are
devisable by 6, is: 48
-- program is finished running --
Write a program using M.I.P.S that asks user “how many positive number that is devisable by...
Has to be written in C++ Write a program that asks the user to enter the month (1-12) and the year (0-2019). Validate the input and print an error and stop the program if an invalid month or year was entered. The program should then display the number of days in that month. Use the following criteria to identify leap years: Determine whether the year is divisible by 100. If it is, then it is a leap year if and...
Is Prime Number In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter a positive integer, and outputs a message indicating whether the integer is a prime number. If the user enters a negative integer, output an error message. isPrime Create a function called isPrime that contains one integer parameter, and returns a boolean result. If the integer input is a prime number, then this function returns...
Language is C 1. Palindrome Write a program that prompts the user for a positive integer number and output whether the number is a palindrome or not. A palindrome number is a number that is the same when reversed. For example, 12321 is a palindrome; 1234 is not a palindromoe. You will write a function named as palindrome. The function will have two arguments, number and isPalindrome. Both arguments are pass-by-reference. The argument number is a pointer to a variable...
In Python, write a program that asks the user for a positive integer number. If the user enters anything else, the program would ask the user to re-enter a number or enter -1 to quit. If it is a positive number, the program then prints out a multiplication table that goes up to that number. For example, if the user enters 10, the output would look something like this. https://www.vectorstock.com/royalty-free-vector/multiplication-table-on-white-background-vector-2721686
python program 6 Write an input validation loop that asks the user to enter a number in the range of 100 through 1000? 7 Write an input validation loop that asks the user to enter ‘Y’, ‘y’, ‘N’, or ‘n’? 8 How many times the following loop will repeat? cnt = 0 while cnt != 5: print(cnt) cnt = cnt + 2
write in C++ Exercise#1: Is it a Prime? Write a program that prompts the user to enter a positive integer in the range [100, 100000]. If the integer is not in the specified range the program prompts the user again. The program prints whether the integer is a prime number or not. Sample input/output nter an integer in the range [10e, 10eeee]: 39 nter an integer in the range [100, 100000]: 120453 Enter an integer in the range [10e, 10e000e]:...
Write a program that asks the user for a student name and asks for grades until the user enters a non-number input, it should then ask if the user wants to enter another student, and keep doing the process until the user stops adding students. The student’s must be stored in a dictionary with their names as the keys and grades in a list. The program should then iterate over the dictionary elements producing the min, max, and mean of...
1. (sumFrom1.cpp) Write a program that will ask the user for a positive integer value. The program should use the for loop to get the sum of all the integers from 1 up to the number entered. For example, if the user enters 50, the loop will find the sum of 1, 2, 3, 4, ... 50. If the user enters a zero or negative number, a message should be given and the program should not continue (see Sample Run...
java program: Write a program which displays the following list on the screen and asks the user to enter either 1 or 2 and perform one of the operations based on the user’s input. If the user enters any other character other than 1 or 2 then display “wrong choice”. LIST OF OPERATIONS 1. Buzz Number 2. Consecutive Odd numbers Note: A BUZZ number is a number which either ends with 7 or is divisible by 7. Sample input 27...
Write a program which asks the user to enter an integer. Use switch statement to write out the numeric word (such as ONE) if the user's input is 1; (see the sample run output for the usr input 2 or 3); otherwise, write OUT OF RANGE. Below are few sample runs: If the user enters a 1, the program will print: ONE TWO THREE Or, if the user enters a 2, the program will print: TWO THREE Or, if the...