Your Java program will be reading input from a file name strīnput.txt. Each record contains String firstname String lastName String strSalary (which will be converted to a double if it's valid – see below) char status String cityState (city and state and combine together but separated by a comma)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 6PE
icon
Related questions
Topic Video
Question

Java program involves the use of Strings, characters and file I/O. 

Your Java program will be reading input from a file name strīnput.txt. Each record
contains
String firstname
String lastName
String strSalary (which will be converted to a double if it's valid – see below)
char status
String cityState (city and state and combine together but separated by a comma)
Sample input:
John Smith 87654.32 F Brooklyn, NY
Jamie Doe 987609.87 F NY,NY
Mike Mantle 345678.30 D Orlando,FL
Frank Young 10456.82 G Boston, MA
Richard Clark 67890.32 D Washington,DC
Jack Şmithson 23489A.82 D Houston, TX
Bob Regan1295609.87 D Denver,Co
Read from the file one record at a time and process as follows:
1. Any record whose status code is neither D or F should be written to the screen
indicating the error. The next record should be read in.
2. If the status code is D or F, validate the salary that it contains only digits and one
decimal point 3 positions from the right (indicating cents).
a. If the salary is invalid, print the entire record to the screen, indicating the
error (char at position x is not a digit or period is missing or period is in the
wrong position).
b. If the salary is valid, convert it to a double.
c. If the status code is D, compute the bonus (double) as 12.5% of salary and
18% if the status code is F.
3. Separate the cityState into two individual Strings named city and state. Use the
position of the comma to help extract the city portion before the comma and the
state after the comma (use indexOf to find the comma and substring to extract the
two parts)
4. Each record that has a status of D should be written to a file named stroutputD
and those record with status of F should be written to a file named stroutputF.
a. For both files, each record printed should include firstName, lastName,
status, salary, bonus, city and state (without the comma)
5. When all records have been read in, print to the screen the number of D, F and
incorrect records processed.
6. Submit your code, the output on the screen and the output in the two files.
Transcribed Image Text:Your Java program will be reading input from a file name strīnput.txt. Each record contains String firstname String lastName String strSalary (which will be converted to a double if it's valid – see below) char status String cityState (city and state and combine together but separated by a comma) Sample input: John Smith 87654.32 F Brooklyn, NY Jamie Doe 987609.87 F NY,NY Mike Mantle 345678.30 D Orlando,FL Frank Young 10456.82 G Boston, MA Richard Clark 67890.32 D Washington,DC Jack Şmithson 23489A.82 D Houston, TX Bob Regan1295609.87 D Denver,Co Read from the file one record at a time and process as follows: 1. Any record whose status code is neither D or F should be written to the screen indicating the error. The next record should be read in. 2. If the status code is D or F, validate the salary that it contains only digits and one decimal point 3 positions from the right (indicating cents). a. If the salary is invalid, print the entire record to the screen, indicating the error (char at position x is not a digit or period is missing or period is in the wrong position). b. If the salary is valid, convert it to a double. c. If the status code is D, compute the bonus (double) as 12.5% of salary and 18% if the status code is F. 3. Separate the cityState into two individual Strings named city and state. Use the position of the comma to help extract the city portion before the comma and the state after the comma (use indexOf to find the comma and substring to extract the two parts) 4. Each record that has a status of D should be written to a file named stroutputD and those record with status of F should be written to a file named stroutputF. a. For both files, each record printed should include firstName, lastName, status, salary, bonus, city and state (without the comma) 5. When all records have been read in, print to the screen the number of D, F and incorrect records processed. 6. Submit your code, the output on the screen and the output in the two files.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning