Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program to do the following: Load up an array of names from the files names.data Assigns integer id's to each name, starting

Write a C++ program to do the following:

  • Load up an array of names from the files names.data
    • Assigns integer id's to each name, starting at 1001, and in the order in which they are read from the file (so the first name would be assigned 1001, the second 1002, etc)
      • We don't have classes yet, so use parallel arrays, i.e., two arrays of the same capacity, the first containing the names, the second the corresponding id
  • Sort the arrays by name
  • Write the sorted data to the file results.data, each name / id pair on a separate line

Sample Test Run #1

For example if the file names.data contains:

Langsam Tenenbaum Arnow Weiss Cox 

upon program termination, the console output should be:

5 records processed. 

the file results.data should contain:

Arnow 1003 Cox 1005 Langsam 1001 Tenenbaum 1002 Weiss 1004 

and the exit code should be 0.

Sample Test Run #2

If the file names.data did not exist, the console output should be:

*** Exception *** input file names.data not found 

and the exit code should be 1.

Sample Test Run #3

If the file names.data contains more than 50 names, the console output should be:

*** Exception *** array capacity exceeded 

and the exit code should be 1.

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

5-23. For living, I require money.

Answered: 1 week ago

Question

=+1. What does healing mean to you now?

Answered: 1 week ago

Question

=+6. What does a good workplace look like to you?

Answered: 1 week ago