Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How do you make a calculator
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rbb




PostPosted: Mon May 12, 2003 8:56 am   Post subject: How do you make a calculator

I was wondering I just got into GUI's and I really don't underastand my assignment of making a calculator how do you do this.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon May 12, 2003 11:59 am   Post subject: (No subject)

same way windows calculator works... you input a number in the textfield... you press a button for operation, you input second number and then you find the result...

Confused Though I might not have understood your question correctly, please specify
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Office of the Registar




PostPosted: Mon May 12, 2003 2:16 pm   Post subject: (No subject)

everytime someone presses a button
store that value.
rbb




PostPosted: Wed May 14, 2003 9:35 am   Post subject: Here is my program so far could I get some help?

Sorry about making a new topic yestersya, my eyes mistake. But anyways I was wondering if ssomeone could help me with the math equations for my calculator, if someone could just show me how to to one function (*,/,+ or -) it would be very appreciated.


Quote:
import GUI in "%oot/lib/GUI"
View.Set ("graphics:290;230")

drawfill (100, 100, grey, grey)
colorback (grey)
color (black)

procedure b1
cls
put "1"
end b1

procedure b2
cls
put "2"
end b2

procedure b3
cls
put "3"
end b3

procedure b4
cls
put "4"
end b4

procedure b5
cls
put "5"
end b5

procedure b6
cls
put "6"
end b6

procedure b7
cls
put "7"
end b7

procedure b8
cls
put "8"
end b8

procedure b9
cls
put "9"
end b9

procedure b10
cls
put "/"
end b10

procedure b11
cls
put "X"
end b11

procedure b12
cls
put "+"
end b12

procedure b13
cls
put "-"
end b13

procedure b14
cls
put "0"
end b14

procedure b15
cls
put "="
end b15

procedure b16
cls
put "+/-"
end b16


loop

var button1 : int := GUI.CreateButton (10, 100, 60, "1", b1)
var button2 : int := GUI.CreateButton (80, 100, 60, "2", b2)
var button3 : int := GUI.CreateButton (150, 100, 60, "3", b3)
var button4 : int := GUI.CreateButton (10, 70, 60, "4", b4)
var button5 : int := GUI.CreateButton (80, 70, 60, "5", b5)
var button6 : int := GUI.CreateButton (150, 70, 60, "6", b6)
var button7 : int := GUI.CreateButton (10, 40, 60, "7", b7)
var button8 : int := GUI.CreateButton (80, 40, 60, "8", b8)
var button9 : int := GUI.CreateButton (150, 40, 60, "9", b9)
var button10 : int := GUI.CreateButton (220, 100, 60, "/", b10)
var button11 : int := GUI.CreateButton (220, 70, 60, "X", b11)
var button12 : int := GUI.CreateButton (220, 40, 60, "-", b12)
var button13 : int := GUI.CreateButton (220, 10, 60, "+", b13)
var button14 : int := GUI.CreateButton (80, 10, 60, "0", b14)
var button15 : int := GUI.CreateButton (150, 10, 60, "=", b15)
var button16 : int := GUI.CreateButton (10, 10, 60, "+/-", b16)
exit when GUI.ProcessEvent
end loop

danu




PostPosted: Sun Jan 11, 2004 1:10 pm   Post subject: i need your help

Hi, did you make te full program!! if you did please e-mail it to damminda@hotmail.com. i really need it.


Quote:
import GUI in "%oot/lib/GUI"
View.Set ("graphics:290;230")

drawfill (100, 100, grey, grey)
colorback (grey)
color (black)

procedure b1
cls
put "1"
end b1

procedure b2
cls
put "2"
end b2

procedure b3
cls
put "3"
end b3

procedure b4
cls
put "4"
end b4

procedure b5
cls
put "5"
end b5

procedure b6
cls
put "6"
end b6

procedure b7
cls
put "7"
end b7

procedure b8
cls
put "8"
end b8

procedure b9
cls
put "9"
end b9

procedure b10
cls
put "/"
end b10

procedure b11
cls
put "X"
end b11

procedure b12
cls
put "+"
end b12

procedure b13
cls
put "-"
end b13

procedure b14
cls
put "0"
end b14

procedure b15
cls
put "="
end b15

procedure b16
cls
put "+/-"
end b16


loop

var button1 : int := GUI.CreateButton (10, 100, 60, "1", b1)
var button2 : int := GUI.CreateButton (80, 100, 60, "2", b2)
var button3 : int := GUI.CreateButton (150, 100, 60, "3", b3)
var button4 : int := GUI.CreateButton (10, 70, 60, "4", b4)
var button5 : int := GUI.CreateButton (80, 70, 60, "5", b5)
var button6 : int := GUI.CreateButton (150, 70, 60, "6", b6)
var button7 : int := GUI.CreateButton (10, 40, 60, "7", b7)
var button8 : int := GUI.CreateButton (80, 40, 60, "8", b8)
var button9 : int := GUI.CreateButton (150, 40, 60, "9", b9)
var button10 : int := GUI.CreateButton (220, 100, 60, "/", b10)
var button11 : int := GUI.CreateButton (220, 70, 60, "X", b11)
var button12 : int := GUI.CreateButton (220, 40, 60, "-", b12)
var button13 : int := GUI.CreateButton (220, 10, 60, "+", b13)
var button14 : int := GUI.CreateButton (80, 10, 60, "0", b14)
var button15 : int := GUI.CreateButton (150, 10, 60, "=", b15)
var button16 : int := GUI.CreateButton (10, 10, 60, "+/-", b16)
exit when GUI.ProcessEvent
end loop

[/quote]
CITC




PostPosted: Sun Jan 11, 2004 7:21 pm   Post subject: (No subject)

functions...

code:
function add (n1, n2 : real) : real
    result n1 + n2
end add

var num1 : real
var num2 : real
get num1
get num2
put add (n1, n2)


theres the basic code for your function of adding.
santabruzer




PostPosted: Sun Jan 11, 2004 8:45 pm   Post subject: (No subject)

i remember i made one in VB.. very simple.. it was very simple..
CITC




PostPosted: Sun Jan 11, 2004 8:51 pm   Post subject: (No subject)

VB would be really easy for something like that... therefore no challenge therefore no fun Smile
santabruzer




PostPosted: Sun Jan 11, 2004 9:00 pm   Post subject: (No subject)

you can have one universal procedure.... you know
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: