logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

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

expert
Ata WhbaLaw
(5/5)

626 Answers

Hire Me
expert
Rick PCriminology
(5/5)

647 Answers

Hire Me
expert
Hariom KasyapFinance
(5/5)

965 Answers

Hire Me
expert
Akshay SinglaResume writing
(5/5)

644 Answers

Hire Me
C++ Programming

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

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. 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

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme