Write MIPS code that emulates a simple calculator. The
calculator initially has the
value 0. Prompt the user to enter a command. A command is a number,
where 0 is add,
1 is subtract, 2 is multiply, 3 is divide, 4 is clear, and 5 is
exit. When the user enters 0,
1, 2, or 3, prompt the user for a number to add, subtract, multiply
or divide from the
current value. If the user enters 4, then clear the current value
(set it to 0). If the user
enters 5, exit the program. Give useful prompts.
(MARS)
calculator.asm:
.data
string1: .asciiz "\nEnter command 0 - add 1- subtract 2 - multiply
3 - Divide 4 - clear 5 - exit: "
string2: .asciiz "Enter number: "
string3: .asciiz "\n result = "
string4: .asciiz "\n******* result cleared *******"
string5: .asciiz "\n******* Terminating Program *******"
.text
li $t0,0 #result variable initially result = 0
loop:
li $v0,4
la $a0,string3 #print string 3
syscall
li $v0,1
move $a0,$t0 #print result
syscall
li $v0,4
la $a0,string1 #print string 1
syscall
li $v0, 5
syscall
move $s0,$v0 #store user choice
beq $s0,4,clear #check user choice if 4 clear
beq $s0,5,exit #check user choice if 5
exit
li $v0,4
la $a0,string2 #print string 2
syscall
li $v0, 5
syscall
move $t1,$v0 #store user numberand perform valid
operation
beqz $s0,addition #check user choice
if 0 add
beq $s0,1,subtraction #check user choice
if 1 subtract
beq $s0,2,multiplication#check user choice if 2
multiply
beq $s0,3,division #check user choice if 3
divide
addition: add $t0,$t0,$t1 # add number to result
j loop
subtraction: sub $t0,$t0,$t1 # subtract number to
result
j loop
multiplication: mul $t0,$t0,$t1 # multiply result with
number
j loop
division: div $t0,$t0,$t1 # divide result with
number
j loop
clear: li $t0,0
li $v0,4
la $a0,string4 #print string
4
syscall
j loop
exit: li $v0,4
la $a0,string5 #print string
5
syscall
li $v0, 10#stop the program and
exit
syscall
Output:



Write MIPS code that emulates a simple calculator. The calculator initially has the value 0. Prom...
Write a calculator that will give the user this menu options: 1)Add 2)Subtract 3)Multiply 4)Divide 5)Exit . Your program should continue asking until the user chooses 5. If user chooses to exit give a goodbye message. After the user selections options 1 - 4, prompt the user for two numbers. Perform the requested mathematical operation on those two numbers. Round the result to 1 decimal place. Please answer in python and make it simple. Please implement proper indentation, not just...
Please make a JAVA program for the following using switch structures Write a program that simulates a simple Calculator program. The program will display menu choices to the user to Add, Subtract, Multiply and Divide. The program will prompt the user to make a selection from the choices and get their choice into the program. The program will use a nested if….else (selection control structure) to determine the user’s menu choice. Prompt the user to enter two numbers, perform the...
Design a calculator program that will add, subtract, multiply, or divide two numbers input by a user.Your program should contain the following:-The main menu of your program is to continue to prompt the user for an arithmetic choice until the user enters a sentinel value to quit the calculatorprogram.-When the user chooses an arithmetic operation (i.e. addition) the operation is to continue to be performed (i.e. prompting the user for each number, displayingthe result, prompting the user to add two...
In this assignment, you will write a subclass of the MemoryCalc
class from Sixth Assignment – Memory Calculator. This new
calculator, called ScientificMemCalc, should be able to do
everything that the MemoryCalc could do, plus raise the current
value to a power and compute the natural logarithm of the current
value. This is a fairly realistic assignment – often when you are
working for a company, you will be asked to make minor extensions
to existing code. You will need...
JAVA QUESTIONDesign a simple calculator for two numbers.Important note. Avoid using IDE's facilities for automatically GUI code generation.Simple Calculator Second Number Multiply 」L Divide First Number Result Add Subtract Power Remainder -
The main method of your calculator program has started to get a little messy. In this assignment, you will clean it up some by moving some of your code into new methods. Methods allow you to organize your code, avoid repetition, and make aspects of your code easier to modify. While the calculator program is very simple, this assignment attempts to show you how larger, real world programs are structured. As a new programmer in a job, you will likely...
A Simple Calculator Summary: Write a console program (character based) to do simple calculations (addition, subtraction, multiplication and division) of two numbers, using your understanding of Java. Description: You need to write a program that will display a menu when it is run. The menu gives five choices of operation: addition, subtraction, multiplication, division, and a last choice to exit the program. It then prompts the user to make a choice of the calculation they want to do. Once the...
Question 20: Write a python program that will perform the operations of simple calculator. The operations are : Addition, subtraction, Multiplication and division. Sample output : Select operation. 1.Add 2.Subtract 3.Multiply 4.Divide Enter choice(1/2/3/4): 3 Enter first number: 15 Enter second number: 14 15 * 14 = 210
Using Java Write a simple calculator which can add, subtract, multiply, and divide. Here are the specifications for the calculator: The calculator has one “accumulator”, which holds the result of all prior calculations. The calculator is set to 0.0 when the calculator is turned on (i.e., instantiated). On the console, the user then enters an operator (+, -, *, or /) and a number. Your console will then apply the operator and operand to the number in the accumulator, and...
7- (50 points) Write a simple calculator in Python which supports four basic mathematical operators (1.e. + - / *). You need to define a module which supports addition, deletion, multiplication and subtraction. Then import your module to your calculator file and use it in your code. The following example shows how your basic calculator needs to work. Select operation: 1.Add 2.Subtract 3.Multiply 4.Divide Enter your choice(1/2/3/4): 3 Enter first number: 12 Enter second number: 14 12 * 14 =...