Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 // Variables for the fields 2 Declare String name 3 Declare Integer idNumber 4 Declare String department 5 6 // Declare an input file.

1 // Variables for the fields 2 Declare String name 3 Declare Integer idNumber 4 Declare String department 

5 6 // Declare an input file. 7 Declare InputFile employeeFile 8 9 // Open a file named employees.dat.

10 Open employeeFile "employees.dat"

10.4 Processing Records 401

11 12 Display "Here are the employee records." 13 14 // Display the records in the file. 15 While NOT eof(employeeFile)

  1. 16 // Read a record from the file.

  2. 17 Read employeeFile name, idNumber, department 

18

  1. 19 // Display the record.

  2. 20 Display "Name: ", name 
  3. 21 Display "ID Number: ", idNumber 
  4. 22 Display "Department: ", department 

23

  1. 24 // Display a blank line.

  2. 25 Display

26 End For 27 28 // Close the file. 29 Close employeeFile

Here are the employee records. Name: Colleen Pickett ID Number: 7311 Department: Accounting

Name: Ryan Pryce ID Number: 8996 Department: Security 
Name: Bonnie Dundee ID Number: 2301 Department: Marketing 

If you are a programmer for a company or an organization, you will most likely have to write programs that read data from files that already exist. The files will probably be stored on the company's servers, or on some other computer that is part of the com- pany's information system. When this is the case, you will not know how the data is organized inside the files. For that reason, companies and organizations usually have a file specification document for each data file. A file specification document describes the fields that are stored in a particular file, including their data types. A programmer who has never previously worked with a particular file can consult that file's specifica- tion document to learn how data is organized inside the file.

A company or organization might keep file specification documents stored as word processing documents, PDF documents, or plain text documents. (In some cases, they might be printed on paper.) The contents of a file specification document will look dif- ferent from one organization to another, but in each case, it will provide the information

402 Chapter 10

Files

that a programmer needs to work with a particular file. Figure 10-20 shows an exam- ple of a file specification document for the employees.dat file that was used in Pro- gram 10-7 and Program 10-8.

Program Statement:

Complete Chapter 10 Programming Exercise 8, with the following modifications:

  1. 1. Create a data file, sales.txt, containing the information as listed in the book.
  2. 2. Write the output listed in the textbook, to the screen and to a data file, titled results.txt.
  3. 3. Place your name and student ID at the top of the output file.
  4. 4. The output should look exactly as listed in the textbook.

Program Requirements:

  1. 1. Design the program using Raptor.
    1. 1. You MUST use Modular Programming techniques by using Sub Modules (Sub Charts in RAPTOR) in your program. Your "main" module should not be very large.

Other Requirements:

  • Documentation: Use the "Comments" feature to document each symbol in the flowchart. You do this by right-clicking the symbol and selecting "Comment." Be sure to identify the data type of each variable used. Be sure to explain what each formula does. Be sure to explain what each of the other symbols in the flowchart does in a comment.
  • Test and debug your Program: Create sample input data, run the program, then check your answers with a calculator or Excel. If something did not match up, then fix your program.
  • Program must execute and produce correct output.
  • Read this page again to be sure you covered all requirements.
  • See the Programming Project Rubric for grading principles.
  • Extra Credit: Add significant functionality or an additional feature to the program. (Suggest a feature to me prior to due date and we will discuss/agree.)

use this as a starting point for the program that you will build using the modifications in the instructions given.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data 29th British National Conference On Databases Bncod 2013 Oxford Uk July 2013 Proceedings Lncs 7968

Authors: Dan Olteanu ,Georg Gottlob ,Christian Schallhart

2013th Edition

3642394663, 978-3642394669

More Books

Students also viewed these Databases questions