28
Computer Science: A Structured Programming Approach Using C 1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in Morse code, patented by Samuel F. B. Morse in 1837, is the language that was used to send 1837, is the language that was used to send messages by telegraph from the middle of the messages by telegraph from the middle of the nineteenth century until the advent of the nineteenth century until the advent of the modern telephone and today’s computer modern telephone and today’s computer controlled communications systems. In this controlled communications systems. In this section, we use a C program to convert English section, we use a C program to convert English to Morse and Morse to English. to Morse and Morse to English.

Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Embed Size (px)

Citation preview

Page 1: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 1

11-7 A Programming Example— Morse CodeMorse code, patented by Samuel F. B. Morse in 1837, Morse code, patented by Samuel F. B. Morse in 1837, is the language that was used to send messages by is the language that was used to send messages by telegraph from the middle of the nineteenth century telegraph from the middle of the nineteenth century until the advent of the modern telephone and today’s until the advent of the modern telephone and today’s computer controlled communications systems. In this computer controlled communications systems. In this section, we use a C program to convert English to section, we use a C program to convert English to Morse and Morse to English. Morse and Morse to English.

Page 2: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 2

Table 11-3 Morse Code

Page 3: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 3

FIGURE 11-26 Character to Morse Code Structure

Page 4: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 4

FIGURE 11-27 Morse Code Menu

Page 5: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 5

FIGURE 11-28 Morse Code Program Design

Page 6: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 6

PROGRAM 11-18 Morse Code: main

Page 7: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 7

PROGRAM 11-18 Morse Code: main

Page 8: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 8

PROGRAM 11-18 Morse Code: main

Page 9: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 9

PROGRAM 11-18 Morse Code: main

Page 10: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 10

PROGRAM 11-18 Morse Code: main

Page 11: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 11

PROGRAM 11-18 Morse Code: main

Page 12: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 12

PROGRAM 11-19 Morse Code: Menu

Page 13: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 13

PROGRAM 11-19 Morse Code: Menu

Page 14: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 14

PROGRAM 11-20 Morse Code: Get Input

Page 15: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 15

PROGRAM 11-20 Morse Code: Get Input

Page 16: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 16

PROGRAM 11-21 Morse Code: Print Output

Page 17: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 17

PROGRAM 11-22 Morse Code: Encode to Morse

Page 18: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 18

PROGRAM 11-22 Morse Code: Encode to Morse

Page 19: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 19

PROGRAM 11-23 Morse code: Decode to English

Page 20: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 20

PROGRAM 11-23 Morse code: Decode to English

Page 21: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 21

PROGRAM 11-24 Morse Code: Convert Codes

Page 22: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 22

PROGRAM 11-24 Morse Code: Convert Codes

Page 23: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 23

11-8 Software Engineering

In this section, we’ve formalized some of the principles In this section, we’ve formalized some of the principles of good programming that we’ve discussed throughout of good programming that we’ve discussed throughout the text. Although you will find little in this discussion the text. Although you will find little in this discussion of software engineering that relates directly to the of software engineering that relates directly to the subject of strings, all of the string functions have been subject of strings, all of the string functions have been written using the principles discussed on the following written using the principles discussed on the following pages.pages.

Program Design ConceptsInformation HidingCohesion

Topics discussed in this section:Topics discussed in this section:

Page 24: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 24

FIGURE 11-29 Types of Cohesion

Page 25: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 25

FIGURE 11-30 Example of Functional Cohesion

Page 26: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 26

ALGORITHM 11-1 Process Inventory Pseudocode

Page 27: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 27

Well-structured programs are highly cohesive and loosely coupled.

NoteNote

Page 28: Computer Science: A Structured Programming Approach Using C1 11-7 A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,

Computer Science: A Structured Programming Approach Using C 28

ALGORITHM 11-2 Process List Pseudocode