Programming with Visual C++: Concepts and Projects Chapter 3B: Integral Data (Tutorial)

Slides:



Advertisements
Similar presentations
Chapter 3: Engage! Android User Input, Variables, and Operations
Advertisements

Chapter 31 Visual Basic Controls A Form is a windows-style screen displayed by Visual Basic programs. In a form, a programmer can create objects in a form.
Visual C++ Programming: Concepts and Projects
Concepts of Database Management Sixth Edition
CODING SYSTEMS CODING SYSTEMS CODING SYSTEMS. CHARACTERS CHARACTERS digits: 0 – 9 (numeric characters) letters: alphabetic characters punctuation marks:
Chapter 2 –Visual Basic, Controls, and Events
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
Variables, Constants, Methods, and Calculations Chapter 3 - Review.
Chapter 4 Introduction to Numeric Data Types and Variables.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and.
Variables and Constants
MATH 224 – Discrete Mathematics
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Interest Calculator Application Introducing the For...Next Repetition Statements.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 1B Introduction (Tutorial)
Chapter 3: Using GUI Objects and the Visual Studio IDE.
Microsoft Visual Basic 2005 BASICS Lesson 4 Mathematical Operators.
Chapter 3 – Fundamentals of Programming in VB.NET VB.NET Controls VB.NET Events Numbers Strings Input and Output.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 2 Creating a User Interface.
Visual Basic.NET BASICS Lesson 4 Mathematical Operators.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 3A Integral Data (Concepts)
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Number Systems Ron Christensen CIS 121.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Concepts of Database Management Seventh Edition
Chapter 2 –Visual Basic, Controls, and Events
Chapter Two Designing Applications Programming with Microsoft Visual Basic th Edition.
Fundamentals of GUI Programming. Objectives: At the end of the session, you should be able to: describe the guidelines that are used for creating user-friendly.
Type Conversions Implicit Conversion Explicit Conversion.
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
Chapter Two Designing Applications Programming with Microsoft Visual Basic th Edition.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Visual C++ Programming: Concepts and Projects Chapter 11B: Pointers (Tutorial)
What is Visual Basic.NET? 110 B-1 e.g. a word processor doesn’t do anything until the user clicks on a button, types text... A programming language that.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 5A Repetition (Concepts)
Programming with Visual C++: Concepts and Projects Chapter 3A: Integral Data (Concepts)
Microsoft Visual Basic 2012 CHAPTER ELEVEN Multiple Classes and Inheritance.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Inventory Application.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 3B Integral Data (Tutorial)
ELEE 4303 Digital II Introduction to Verilog. ELEE 4303 Digital II Learning Objectives Get familiar with background of HDLs Basic concepts of Verilog.
Programming with Visual C++: Concepts and Projects Chapter 4B: Selection (Tutorial)
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
CONVERTING TO RATIONAL NUMBERS. Whole numbers are 0, 1, 2, 3, 4, … Integers include all the whole numbers and also their negative versions: …, -3, -2,
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Making Interactive Programs with Visual Basic .NET
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Microsoft Visual Basic 2010 CHAPTER FOUR Variables and Arithmetic Operations.
Some basic concepts underlying computer archi­tecture
Visual C++ Programming: Concepts and Projects
Microsoft Visual Basic 2005: Reloaded Second Edition
A variable is a name for a value stored in memory.
Variables and Arithmetic Operations
Chapter 3 Fundamentals of Programming in Visual Basic 3
Variables and Arithmetic Operations
Tutorial 12 – Security Panel Application Introducing the Select Case Multiple-Selection Statement Outline Test-Driving the Security Panel Application.
Presenting information as bit patterns
Data Types and Expressions
F T T T F.
Presentation transcript:

Programming with Visual C++: Concepts and Projects Chapter 3B: Integral Data (Tutorial)

Tutorial: Binary Conversion Program 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 is displayed Its decimal representation 65 is displayed Programming with Visual C++: Concepts and Projects2

Problem Analysis Programming with Visual C++: Concepts and Projects3

Problem Analysis (continued) The ASCII code of the letter is a base-10 integer – no explicit conversion required! To calculate the binary representation: – Start with largest binary place value (128) – Determine how many whole times the place value goes into the integer in question (using integer division) – Display result – Capture remainder (using mod) Programming with Visual C++: Concepts and Projects4

Problem Analysis (continued) Programming with Visual C++: Concepts and Projects5

Problem Analysis (continued) Programming with Visual C++: Concepts and Projects6

Problem Analysis (continued) Programming with Visual C++: Concepts and Projects7

Problem Analysis (continued) Programming with Visual C++: Concepts and Projects8

Design 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 ) Programming with Visual C++: Concepts and Projects9

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

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

Design (continued) Programming with Visual C++: Concepts and Projects12 Variables required – The character entered by the user in txtChar – The integer corresponding to that character (used to produce the binary representation)

Design (continued) Programming with Visual C++: Concepts and Projects13 The starting point for this solution is a high- level algorithm Step 3 needs much more development

Design (continued) Programming with Visual C++: Concepts and Projects14 Low-level algorithm for Step 3

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

Development 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 ) Programming with Visual C++: Concepts and Projects16

Development (continued) Programming with Visual C++: Concepts and Projects17 Create interface with textBox1 and label1 Set textBox1 properties – Change the size to 42, 62 – Change the Font to Microsoft Sans Serif 16Change the MaxLength property of textBox1 to 1 so that the user can only enter 1 character into it

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

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

Development (continued) Programming with Visual C++: Concepts and Projects20 Create 8 more textboxes – Select them all using the Ctrl key – Change the sizes to 42, 62 – Change the Font to Microsoft Sans Serif 16 – Decrease the horizontal spacing – Change BackColor color to Black and ForeColor to LimeGreen

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

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

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

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

Development (continued) Programming with Visual C++: Concepts and Projects25 Rename all textBoxes – txtChar – txt128, txt64, txt32, txt16, txt8, txt4, txt2, txt1 Add additional controls and set properties

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

Development (continued) Code Form1_Load() event handler – Put 0’s in all binary digit textBoxes – Put “ “ in txtChar – Put instructions in txtInstruct Programming with Visual C++: Concepts and Projects27

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

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

Development (continued) Code btnConvert_Click() – Assign first character in txtChar to variable Programming with Visual C++: Concepts and Projects30

Development (continued) Code btnConvert_Click() – Assign character to an integer variable – Display the base-10 integer Programming with Visual C++: Concepts and Projects31

Development (continued) Code btnConvert_Click() – Display groups of 128 – Calculate remainder Programming with Visual C++: Concepts and Projects32

Development (continued) Code btnConvert_Click() – Display other place values Programming with Visual C++: Concepts and Projects33

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

Testing 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 Programming with Visual C++: Concepts and Projects35

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

On Your Own 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 /= %= Programming with Visual C++: Concepts and Projects37