Please design a GUI and program it to be a standard calculator. It should be abl
ID: 3685655 • Letter: P
Question
Please design a GUI and program it to be a standard calculator. It should be able to calculate addition, subtraction, multiplication, division, squareroot and a reciprocal. The calculator has the following buttons: Back space (delete the last number entered) MS (store a displayed number in memory), MR (recall the stored number), MC (clear the memory), CE (clear the last entry) C (clears everything except a number in memory). The memory can store just one number. For the reference, you can run a calculator located in Start rightarrow All Programs rightarrow Accessories rightarrow Calculator in MS Window. When you display the result, please round up the numbers to three decimal places.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