Figure 7 4 flowchart and pseudocode for program that

This preview shows page 6 - 9 out of 23 pages.

Figure 7-4 Flowchart and pseudocode for program that uses files
In the program in Figure 7-4 , after each employee’s pay rate is read into memory, it is increased by $2.00. The value of the pay rate on the input storage device is not altered. When processing is complete, the input file retains the original data for each employee, and the output file contains the revised data. Many organizations would keep the original file as a backup file. A backup file is a copy that is kept in case values need to be restored to their original state. The backup copy is called a parent file and the newly revised copy is a child file . Logically, the verbs print, write , and display mean the same thing all produce output. In conversation, however, programmers usually reserve the word print for situations in which they mean produce hard copy output . Programmers are more likely to use write when talking about sending records to a data file and display when sending records to a monitor. In some programming languages, there is no difference in the verb used for output regardless of the hardware; you simply assign different output devices (such as printers, monitors, and disk drives) as needed to programmer-named objects that represent them. Watch the video File Operations . Throughout this book, you have been encouraged to think about input as basically the same process, whether it comes from a user typing interactively at a keyboard or from a stored file on a disk or other media. The concept remains valid for this chapter, which discusses applications that commonly use stored file data. Two Truths & a Lie Performing File Operations 1. You give a file an internal name in a program and then associate it with the operating system’s name for the file.
2. When you read from a file, you copy values from memory to a storage device.
When you read from a file, you copy values from a storage device into memory. When you write to a file, you copy values from memory to a storage device. 3. If you fail to close an input file, usually no serious consequences will occur; the data values still exist in the file. T F 7-4 Understanding Control Break Logic A control break is a temporary detour in the logic of a program. In particular, programmers use a control break program to do the following: Read in records from a sorted sequential file so that all records that belong to specific groups are stored together in sequence. Process each record, checking to determine if it still belongs to the same group as the previous record. Pause for special processing whenever a new group of records is encountered. For example, a control break program might be used to generate a report that lists all company clients in order by state of residence, with a count of clients after each state’s client list. See Figure 7-5 for an example of a control break report that breaks after each change in state.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture