Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)

Similar presentations


Presentation on theme: "Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)"— Presentation transcript:

1 Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)

2 Tutorial: Addition Program Problem Analysis – Create an addition program for double precision numbers Design – Sketch the interface – Identify required controls for input, processing and output – Identify the variables to store two numbers and their sum – Construct an algorithm for input, processing and output Programming with Visual C++: Concepts and Projects

3 Tutorial: Addition Program Development –Create the interface –Code the event handlers Testing Programming with Visual C++: Concepts and Projects

4 Design Programming with Visual C++: Concepts and Projects Interface sketch – Position each control object on the form as it should look in the finished product – Name each control object

5 Design (continued) Programming with Visual C++: Concepts and Projects

6 Design (continued) Programming with Visual C++: Concepts and Projects Control table – List the control objects from the interface sketch – Identify their usage (input, processing, output) – List any events associated with them

7 Design (continued) Programming with Visual C++: Concepts and Projects Data Table – Identify variables that will be required, by name – Assign a data type to each variable ( double in this case) – Describe the purpose of the variable

8 Design (continued) After the interface has been designed algorithms must be written for each event handler This program has a button The button has a click event handler requiring an algorithm Programming with Visual C++: Concepts and Projects

9 Design (continued) Algorithm 1.Declare variables 2.Read num1 3.Read num2 4.Compute sum 5.Display sum Programming with Visual C++: Concepts and Projects

10 Development Programming with Visual C++: Concepts and Projects Create the actual interface based on the preliminary sketch you did in the Design stage – Place control objects on the form – Set the properties of these objects

11 Development (continued) Programming with Visual C++: Concepts and Projects

12 Development (continued) Programming with Visual C++: Concepts and Projects

13 Development (continued) Programming with Visual C++: Concepts and Projects

14 Development (continued) The Development stage is where the code must be written for each event handler Before writing any Visual C++ code you must have a plan (an low-level algorithm) Ideally, from each line of the algorithm a Visual C++ statement can be constructed Programming with Visual C++: Concepts and Projects

15 Development (continued) Programming with Visual C++: Concepts and Projects

16 Development (continued) Programming with Visual C++: Concepts and Projects

17 Development (continued) Comments should be added to your code at regular intervals Comments are ignored by the compiler Comment syntax – Line comment Used for one line, or a portion of a line // – Block comment Used for multiple lines of comments /* … */ Programming with Visual C++: Concepts and Projects

18 Development (continued) Programming with Visual C++: Concepts and Projects

19 Testing Run the program and enter various numbers into the Textboxes – Check the displayed result for accuracy Programming with Visual C++: Concepts and Projects

20 Testing (continued) Programming with Visual C++: Concepts and Projects

21 On Your Own Modify the interface – Rearrange the control objects Add more operations – Implement addition, subtraction, multiplication and division – Additional buttons are required for each operation Programming with Visual C++: Concepts and Projects

22 On Your Own (continued) Programming with Visual C++: Concepts and Projects

23 On Your Own (continued) Programming with Visual C++: Concepts and Projects


Download ppt "Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)"

Similar presentations


Ads by Google