Download presentation
Presentation is loading. Please wait.
Published byRhoda Arnold Modified over 9 years ago
1
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 3B Integral Data (Tutorial)
2
Tutorial: Binary Conversion Program Visual C++ Programming 2 Problem Analysis Construct a program that allows the user to enter a character and see its decimal (base-10) and binary (base-2) representations For example, if the user entered the letter ‘A’ Its binary representation 01000001 is displayed Its decimal representation 65 is displayed
3
Visual C++ Programming 3
4
Problem Description Visual C++ Programming 4 The ASCII code of the letter is a base-10 integer – no explicit conversion required! To calculate the binary representation Start with the largest binary place value (128) Determine how many whole times the place value goes into the integer in question (using integer division) Display the result Capture the remainder (using mod)
5
Visual C++ Programming 5
6
6
7
7
8
8
9
Design Visual C++ Programming 9 Interface sketch requires numerous textboxes Data entry (txtChar) Data output Eight textboxes for the binary digits One textbox (txtDec) for the decimal version Control table Data table Algorithm for the button (btnConvert)
10
Visual C++ Programming 10
11
Visual C++ Programming 11
12
Visual C++ Programming 12
13
Visual C++ Programming 13
14
Visual C++ Programming 14
15
Visual C++ Programming 15
16
Development Visual C++ Programming 16 Create the interface Create, resize and position multiple textboxes Set MaxLength property to 1 for txtChar Set horizontal spacing Add labels Change ForeColor and BackColor Assign names to match interface design Add a textbox for instructions ( txtInstruct )
17
Visual C++ Programming 17
18
Visual C++ Programming 18
19
Visual C++ Programming 19
20
Visual C++ Programming 20
21
Visual C++ Programming 21
22
Visual C++ Programming 22
23
Visual C++ Programming 23
24
Visual C++ Programming 24
25
Visual C++ Programming 25
26
Visual C++ Programming 26
27
Visual C++ Programming 27
28
Visual C++ Programming 28
29
Visual C++ Programming
30
Development (continued) Visual C++ Programming 30 Code Form1_Load() event handler Code btnConvert_Click() Assign first character in txtChar to variable Assign character to an integer variable and display Display groups of 128 Calculate remainder Display other place values
31
Visual C++ Programming 31
32
Visual C++ Programming 32
33
Visual C++ Programming 33
34
Visual C++ Programming 34
35
Visual C++ Programming 35
36
Visual C++ Programming 36
37
Visual C++ Programming 37
38
Visual C++ Programming 38
39
Visual C++ Programming 39
40
Testing Visual C++ Programming 40 Demonstrate that your program works with A-Z characters a-z characters 0-9 numerals Punctuation marks and special characters Use the ASCII table in Appendix B to verify correctness
41
Visual C++ Programming 41
42
On Your Own Visual C++ Programming 42 Demonstrate your understanding Create a diagram like Figure 3-28 to show how your program works with various decimal numbers Replace ToString() with Convert::ToString() Use shorthand operators /= %=
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.