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

You will be using GUIDE to develop an INTEGER calculator. This calculator will a

ID: 3554606 • Letter: Y

Question

You will be using GUIDE to develop an INTEGER calculator. This calculator will allow input via the buttons only. You can add multiple calculations on one line

5 + 6 * 2

Your code must check the inputs to be sure they contain only valid numbers and operators, and if not, display an error message in the Result text box.

You must also ensure that division by zero is not possible. If the user tries to divide by zero, the calculation should not be attempted, and an error message should appear in the Result text box.

You will want to create an empty string which will hold your equation. At each button press, add that symbol or number to the end of the string. When the Equals button is pressed, the equation is validated, evaluated and the result placed in the text box on top.

The clear button should clear the Result box.

Explanation / Answer

function calculator

figure('Position',[200 200 220 200],'Name','Calculator','NumberTitle','off','MenuBar','None','Resize','off');

txt=uicontrol('Style','Text','Position',[10 165 200 30],'String','0');

global stack value top op tops opstack num1 num2 flag;

flag=0;

x=10;

y=130;

top=1;

tops=1;

name=['7','8','9','/','4','5','6','*','1','2','3','-','0','+','C','='];%k

for k=1:size(name,2)

   

   uicontrol('Style','Pushbutton','Position',[x y 50 30],'String',name(k),'Callback',@arithmetic) ;

   x=x+50;

   if(mod(k,4)==0)

   

       x=10;y=y-35;

      

   end

end

The String value of the pressed button is obtained using theget(object,

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