Presentation is loading. Please wait.

Presentation is loading. Please wait.

Problem: Take Two Numbers, Add Them Together And Display The Results. Now To Build The Flowchart… We Probably Need One Like This… Let’s Add The Routines…

Similar presentations


Presentation on theme: "Problem: Take Two Numbers, Add Them Together And Display The Results. Now To Build The Flowchart… We Probably Need One Like This… Let’s Add The Routines…"— Presentation transcript:

1

2 Problem: Take Two Numbers, Add Them Together And Display The Results. Now To Build The Flowchart… We Probably Need One Like This… Let’s Add The Routines… Start Get Number 1 Get Number 2 Number 3 = Number 1 + Number 2 Display Number 3 Stop What Now??? Let’s Program Using It. Which Language Do You Want To Use? C++, Visual C++ Or Visual Basic? Let’s Start With C++

3 Let’s Put The Chart Up For A Reference. Now We Begin With A Comment Line. // Program Name: Test.cpp Then We Include A Reference To The iostream File. #include Now We Setup Our Main Routine. void main( ) { Then Define Our Integers. int test1; int test2; int test3; Get Input From User And Store It In Integers. cout << “Enter number 1:”; cin >> test1; cout << “\n”; cout << “Enter number 2:”; cin >> test2; We Add Them Together. test3 = test1 + test2; And Print The Results. cout << “The total is: \n”; cout << test3; cout << “\n”; } Compile And Run The Program.

4 Program It In…

5 Select MFC AppWizard(exe) First Open Visual C++ Type In A File Name

6 Select Dialog Based And Press Next

7 Press Next, We Are Going To Use The Defaults On This Screen.

8 Press Next, Again We Will Use The Defaults.

9 Now We Can Press Finished. The Wizard Will Build Our Program.

10 After The Wizard Is Finished, We Get This. We Can’t Use It Like It Is, We Need To Make Changes. Delete This First. Then Move Our Buttons Down To About Here. Add Three Edit Boxes About Here. You Get The Edit Boxes From Your Tool Box

11 Right Click On The Buttons To Change Properties. Change ID To IDADD and Caption To ADD. This Is A Reference Name To The Control In Your Program.. This Is The Displayed Caption. Change The Cancel Button To Exit.

12 It Should Look Like This Now. Now We Program The Code. Select The Exit Button. Right Click On The Exit Button And Select ClassWizard

13 Select IDCANCEL BNCLICKED ADD Function When This Box Shows, Press OK Then Press Edit Code

14 A Section Of Code Will Appear. Add OnOK(); Type It Exactly As Shown. C++ Is Case Sensitive. Now Our Exit Button Works…

15 To Define Our Variables, Select ClassWizard Again. Press The Second Tab. Select Edit1. Now Press Add Variables

16 Type In m_Test1 Change This To Int. We Are Using Integers. Press OK Do The Same Thing On Edit2 And Edit3, But Rename The Variables To m_Test2 And m_Test3 To Match The Edit Boxes.

17 Select ClassWizard Again. Select IDADD BN_CLICKED Press Edit Code We Are Going To Put In Our ADD Routine.

18 Type In Exactly As Shown… UpdateData(TRUE); m_Test3 = m_Test1 + m_Test2; UpdateData(FALSE); Congratulations… Our Program Is Now Finished. Compile And Run The Program.

19 From A Flowchart... To A Working Program.

20 Program It In…

21 Start Visual Basic And Select Standard EXE. Then Press Open

22 A Blank Form Box Will Appear. Add Three Text Boxes From The ToolBox On To The Form. Add Two Buttons From The ToolBox On To The Form.

23 Select Command1 Button. Under The Caption Properties, Change To ADD. Change Command2 Caption Property To Exit.

24 Select Text1 Clear The Text Property So The Text Box Will Be Clear. Do The Same For Text2 And Text3

25 Double Click On The Exit Button And Insert The Following Code… Unload Me

26 Double Click On The Add Button And Add The Following Code... Text3.Text = val(Text1.Text) + val(Text2.Text) The Program Is Now Finished

27 From A Flowchart… To A Working Program.

28


Download ppt "Problem: Take Two Numbers, Add Them Together And Display The Results. Now To Build The Flowchart… We Probably Need One Like This… Let’s Add The Routines…"

Similar presentations


Ads by Google