Program that processes a string data file

Assignment Help Basic Computer Science
Reference no: EM131979954

  • Working with arrays
  • Using file operations
  • Using a selection sort to sort string arrays
  • Using a function to display arrays
  • Using a function to save arrays to file
  • Implementing functions besides function main()

Project Description

C++ program that processes a string data file. The program will 1) read the names from a string data file and place them in an array, and 2) sort the names in the array in ascending order using selection sort. The program will use a function to display the array before it is sorted and AFTER it is sorted. A separate function should be implemented to save the sorted names to a data file called "sortedNames.txt."

Project Specifications

Input for this project: you may use the attached data file "names.txt" for testing, or a string data file of your own. Assume the file contains at least 20 names, each written on a separate line. The user must enter the number of names to process and names of the input file and output file.

Output: If the input file does not open, an error message should appear on the console. The program should have the follow output:

  • Display the names in the array before sorting (unsorted list)
  • Display the names in the array after sorting (sorted list)
  • Save the sorted array to a data file

Processing Requirements

Define all functions after main function and prototype them properly. Assume that the data file contains 20 names on separate lines and is constructed correctly.

Create four functions for the following:

1. Function Read the names from the data file: Prompt for and get the input file name and try to open the file. If the file opens, read the names from the file, store them into the array. If the file does NOT open, print an error message on the console. If the file is not found, do NOT process the names. The function accepts two arguments: array of string and array size

2. Function Display the unsorted array. The function accepts two arguments: array of string and array size 

3. Function Display the sorted array. The function accepts two arguments: array of string and array size 

4. Function Save the sorted array to a data file. Prompt the user for data file name. The function accepts two arguments: array of string and array size

Sample Input File:

Collins, Bill

Smith, Bart

Allen, Jim,

Griffin, Jim

Stamey, Marty

Rose, Geri,

Taylor, Terri

Johnson, Jill,

Allison, Jeff

Looney, Joe

Wolfe, Bill,

James, Jean

Weaver, Jim

Pore, Bob,

Rutherford, Greg

Javens, Renee,

Harrison, Rose

Setzer, Cathy,

Pike, Gordon

Holland, Beth

Sample Output File:

Names in Ascending Order:

Allen, Jim,

Allison, Jeff

Collins, Bill

Griffin, Jim

Harrison, Rose

Holland, Beth

James, Jean

Javens, Renee,

Johnson, Jill,

Looney, Joe

Pike, Gordon

Pore, Bob,

Rose, Geri,

Rutherford, Greg

Setzer, Cathy,

Smith, Bart

Stamey, Marty

Taylor, Terri

Weaver, Jim

Wolfe, Bill,

Reference no: EM131979954

Questions Cloud

Make a javafx application : Make a JavaFX application - CircleOverlap.java - that presents 20 circles (use the JavaFX Circle class), each with a random radius and location.
Write a research paper on how did hurricane katrina impact : Write 7-10 page research paper on how did Hurricane Katrina impact the US Economy. Logistics of the Essay -Must use specified essay style (argumentative).
Passwords with numbers and upper and lower case letters : The CFATS RBPS Metric 8.2.5, Password Management standard includes the following recommendations (choose all that apply).
Full disk encryption in windows to protect user data : Microsoft's BitLocker provides full disk encryption in Windows to protect user data. It is specifically useful if one's computer is physically
Program that processes a string data file : C++ program that processes a string data file. The program will 1) read the names from a string data file and place them in an array
Rdbms based on workforce skill and availability : Explain why it may be more efficient for a company to utilize an RDBMS based on workforce skill and availability. Discuss how a company might
What effects do joining a cult have on a person : Create an argumentative thesis statement and write on the culture of the topic. What effects do joining a cult have on a person?
Describe the actions of any major characters in hamlet : Describe the actions of any major characters in Hamlet, applying two tests which any ethical action must pass: (1) The Golden Rule and (2) universality.
Different conversion type : A measurement from inches to centimeters or vice versa. Use the program-defined functions: one for each different conversion type.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd