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

929 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

692 Answers

Hire Me
expert
Husnain SaeedComputer science

901 Answers

Hire Me
expert
Atharva PatilComputer science

500 Answers

Hire Me
April
January
February
March
April
May
June
July
August
September
October
November
December
2025
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
SunMonTueWedThuFriSat
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30