logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Write a program to open an input file and output file. The user is prompted for both filenames and the program must verify that both files opened.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Write a program to open an input file and output file. The user is prompted for both filenames and the
program must verify that both files opened. The file contains first and last names separated by a space.
Some individuals listed are only known by their first name, in these cases, “noLastName” has been put
as a place holder in the file to make processing easier. Replace “noLastName” with “ “ in the output.
The program should open using the filename provided by the user for input and the supplied output
filename for writing. The user is prompted as to whether the entire file should be read. If yes, then all
records in the file should be processed until end of file is reached. If no, then only the specified records
are processed.
The program reads the first and last name fields from the input file. The header should be written to
the output file first, see examples for formatting. As each name is read from the input file, the current
record number along with the name are written out to the output file. Each name is assigned a droid
type and model. If the first name indicates the person is in a management position, they are
automatically assigned an administrative droid type. The model of the droid is decided by selecting a
random number, which is mapped to the types and models using the following enumerated types.
enum DROID_TYPES { ADMINISTRATIVE, MAINTENANCE, PROTOCOL, ASTROMECH };
enum ADMINISTRATIVE_TYPES { ET_74, XA_540, a3D_4X};
enum MAINTENANCE_TYPES { F1_DX, EB_89, CB_2B, SA_45};
enum PROTOCOL_TYPES {C3PO, L80, SA_5, RA_7 };
enum ASTROMECH_TYPES { M4_Y6, BB_8, D3_S5, R2_D2};
Figure 1: By yari hotaka from Japan - 田んぼアート Original version, CC BY 2.0,
https://commons.wikimedia.org/w/index.php?curid=49714962
Individuals that do not have titles showing they are in management, have a droid type and model
selected for them randomly.
The type and model assigned are written to the output file after the first and last names. The number of
each type of droid assigned should be kept in a counter and total output at the end of the file.
File Data Format:
The file format is as follows:
Admiral Sarn
Saul Karath
Assignment Notes
The random number generator returns an integer, which needs to be converted to the type specified.
Because enumerated data types are base on the integer data type, a simple static cast can be used to
convert the integer from the random number to the desired enumerated data type.
Example
DROID_TYPES droid=ADMINISTRATIVE;
int value =0;
value = rand( ) % 5; // random number limited in range from 0-4.
// assign the integer to droid
droid = static_cast<DROID_TYPE> (value);
// now droid maybe used in a switch statement with case labels of the enumerated type
//DROID_TYPES.
Random Number Generator Notes
Do not initialize the random number generator seed with srand().
File Input Notes:
If the user selected to read the entire file, then all data in the file should be processed. If the user
selected to enter a number of lines to process, then the only the entered number of lines should be read
and included in the statistics. Be aware that the user may enter a number that is larger than the number
of lines of data in the file. When the program stops reading the file, a message should be displayed
stating why the reading stopped, end of file or maximum number of records requested. See example
for formatting information.
Input File:
The data file is on the canvas website.
Compiling
Purpose:
Become familiar with basic C++ syntax, input/output, if statements, C++ looping structures, file I/O,
output formatting and recovering from bad input that causes the input stream to go to the fail state.
Rebel Alliance Computational Support has been asked to write a program to assign droids to personnel.
The droids are randomly assigned to each person, unless the person is a manager, then they are always
assigned an administrative droid. Managers have a title in place of their first name and include
Admiral, Captain, Commander, Darth, Emperor, and Queen. All other individuals have the droid type
and model assigned using the random number generator.
Assignment:
Write a program to open an input file and output file. The user is prompted for both filenames and the
program must verify that both files opened. The file contains first and last names separated by a space.
Some individuals listed are only known by their first name, in these cases, “noLastName” has been put
as a place holder in the file to make processing easier. Replace “noLastName” with “ “ in the output.
The program should open using the filename provided by the user for input and the supplied output
filename for writing. The user is prompted as to whether the entire file should be read. If yes, then all
records in the file should be processed until end of file is reached. If no, then only the specified records
are processed.
The program reads the first and last name fields from the input file. The header should be written to
the output file first, see examples for formatting. As each name is read from the input file, the current
record number along with the name are written out to the output file. Each name is assigned a droid
type and model. If the first name indicates the person is in a management position, they are
automatically assigned an administrative droid type. The model of the droid is decided by selecting a
random number, which is mapped to the types and models using the following enumerated types. 

enum DROID_TYPES { ADMINISTRATIVE, MAINTENANCE, PROTOCOL, ASTROMECH }; enum ADMINISTRATIVE_TYPES { ET_74, XA_540, a3D_4X}; enum MAINTENANCE_TYPES { F1_DX, EB_89, CB_2B, SA_45}; enum PROTOCOL_TYPES {C3PO, L80, SA_5, RA_7 }; enum ASTROMECH_TYPES { M4_Y6, BB_8, D3_S5, R2_D2}; Figure 1: By yari hotaka from Japan - 田んぼアート Original version, CC BY 2.0, https://commons.wikimedia.org/w/index.php?curid=49714962 Individuals that do not have titles showing they are in management, have a droid type and model selected for them randomly. The type and model assigned are written to the output file after the first and last names. The number of each type of droid assigned should be kept in a counter and total output at the end of the file. File Data Format: The file format is as follows: Admiral Sarn Saul Karath Assignment Notes The random number generator returns an integer, which needs to be converted to the type specified. Because enumerated data types are base on the integer data type, a simple static cast can be used to convert the integer from the random number to the desired enumerated data type. Example DROID_TYPES droid=ADMINISTRATIVE; int value =0; value = rand( ) % 5; // random number limited in range from 0-4. // assign the integer to droid droid = static_cast (value); // now droid maybe used in a switch statement with case labels of the enumerated type //DROID_TYPES. Random Number Generator Notes Do not initialize the random number generator seed with srand(). File Input Notes: If the user selected to read the entire file, then all data in the file should be processed. If the user selected to enter a number of lines to process, then the only the entered number of lines should be read and included in the statistics. Be aware that the user may enter a number that is larger than the number of lines of data in the file. When the program stops reading the file, a message should be displayed stating why the reading stopped, end of file or maximum number of records requested. See example for formatting information. Input File: The data file is on the canvas website. Compiling The program should compile with no warnings or errors using the flags: -pedantic -Wall -Wextra

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

874 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

774 Answers

Hire Me
expert
Husnain SaeedComputer science

584 Answers

Hire Me
expert
Atharva PatilComputer science

742 Answers

Hire Me

Get Free Quote!

336 Experts Online