subject

fileio – creating email addresses and life insurance payout
you have been given the assignment to create email addresses and the average life insurance payout for each beneficiary
of an employee from an input file of employees. the input and output files have every field in each record separated by a
%. the record layouts are:
for example, the records in the input file look like this:

mary%beth%jones%1%3
thomas%peter%morris%15000%2
john%quincy%smith%0%0
karl%emerson%jackson%2%4
gary%b%jones%0%0
betty%jo%nelson%1%1

the average beneficiary payout in the output file is calculated by dividing the employee’s life insurance amount by
the employee’s number of beneficiaries. if an employee has no beneficiaries (see john quincy smith and gary b. jones
above), you should avoid a “division by zero” runtime error by using a try/catch block. an exception report should be
written to the console when this occurs, and that employee’s output record should not be written.
for you to build the email address for each employee, you will need to get the company name from the console. then,
each employee’s email address will be built using the first and middle initials appended to the last name followed by an @
sign, followed by the company name and .com. all email addresses must be in lower case.
because you are working with file input, your main method statement should throw an exception. use the following
format:
public static void main(string[] args) throws exception {
}
algorithm: examples of reading data from a file and writing data to a file are found in blackboard.
1. create the file object from the file class for the output file.
2. if the file exists, put a message to the console saying file already exists and exit program (return code = 0).
3. get the domain name from the console and build the second part of the email address “@companyname. com”.
4. create a new object from the scanner class for the input file.
5. create string variables for firstname, middlename, and lastname.
6. create an output object from the printwriter class for the output file.
7. using a “while” loop and the hasnext method, split the input record into variables by using string[] tokens =
record. split("%",0); . assign the tokens into variables.
8. calculate averagebeneficiarypayout. use try/catch block for zero beneficiaries and put the exception report
info to the console.
9. build email address using substring method and then output all fields using the output. println method to the
output file.
10. after writing all output, close the output file - output.
11. print to the console that the output file was written successfully.
sample run:
enter domain name (e. g. ncc):
companyname
exception report:
input file: employeelifeinsurance. txt
first name: string
middle name: string
last name: string
life insurance amount: int
number of beneficiaries: int
output file: .txt
first name: string
middle name: string
last name: string
average beneficiary payout: int
employee email address: string
john quincy smith has zero beneficiaries and was skipped
gary b jones has zero beneficiaries and was skipped
.txt file was written successfully.
output file:
mary%beth%jones%%mbjones@companynam e. com
thomas%peter%morris%7500%tpmorris@c ompanyname. com
karl%emerson%jackson%5%kejackson@co mpanyname. com
betty%jo%nelson%1%bjnelson@companyn ame. com

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:40
You begin your first day of responsibilities by examining the recent is security breach at gearup to get ideas for safeguards you will take. at gearup, criminals accessed the company's improperly-secured wireless system and stole customers' credit card information as well as employee social security numbers. what kind of computer crime did gearup face?
Answers: 3
question
Computers and Technology, 22.06.2019 18:30
The "instance" relationship shows that something is an object of a
Answers: 1
question
Computers and Technology, 22.06.2019 23:50
List a few alternative options and input and output over the standerd keyboard and monitor. explain their functioning in details.
Answers: 2
question
Computers and Technology, 23.06.2019 07:00
Why were most movies from the late 1890s until the early 1930s only filmed in black and white? there were only a few people who could afford the technology to produce color motion pictures back then. audiences did not want color motion pictures until later. the film used to make color motion pictures often overheated, which was a safety hazard, so it was generally not allowed. color films had to be hand-colored, frame by frame.
Answers: 3
You know the right answer?
fileio – creating email addresses and life insurance payout
you have been given the assignment...
Questions
question
Biology, 28.10.2019 21:31
question
Mathematics, 28.10.2019 21:31
question
Chemistry, 28.10.2019 21:31
Questions on the website: 13722363