1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tankabanditka [31]
3 years ago
13

Your Java program will be reading input from a file name strInput.txt. Each record contains String firstname String lastName Str

ing 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:
Ira Rudowsky 87654.32 F Brooklyn.NY
Jane Doe 987609.87 F NY NY
Mickey Mantle 345678.30 D Orlando FL
Fran Young 10456A.82 G Boston MA
Richard Clark 67890.32 D
Serena liams 1295609.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 comma to extract the city portion before the comma and the state after the comma
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 strOutputRE.
a. For both files, each record printed should include firstName, lastName, status, salary, bonus, city and state
5. When all records have been read in, print to the screen the number of D, F and incorrect records processed
Engineering
1 answer:
stiks02 [169]3 years ago
6 0

Answer:

The program requires that you have the specified input files and it reads from each file at a time and processes salary in digits, states the city, state and bonus with respective first and last name as requested in the question. Note that you must have access to the mentioned output files for the program to work properly. Below is the java version of the program.

import java.io.File;

import java.io.FileNotFoundException;

import java.io.PrintWriter;

import java.util.Scanner;

class Driver

{

public static void main(String[] args) throws FileNotFoundException

{

Scanner sc = new Scanner(new File("strInput.txt"));

PrintWriter pd = new PrintWriter(new File("strOutputD"));

PrintWriter prf = new PrintWriter(new File("strOutputRF"));

String firstname = "", lastname = "", strSalary = "", status = "", cityState = "", city = "", state = "";

double salary = 0, bonus = 0;

int incorrectRecords = 0;

int dRecords = 0;

int fRecords = 0;

while(sc.hasNextLine())

{

firstname = sc.next();

lastname = sc.next();

strSalary = sc.next();

status = sc.next();

cityState = sc.next();

if(!status.equals("D") && !status.equals("F"))

{

System.out.println("Records is neither D nor F. Skipping this...");

incorrectRecords++;

continue;

}

else if(status.equals("D") || status.equals("F"))

{

char c = ' ';

int i = 0;

for(i=0; i<strSalary.length() && c != '.'; i++)

{

c = strSalary.charAt(i);

if(!Character.isDigit(c))

{

System.out.println("Char at position " + (i+1) + " in salary is not a digit");

incorrectRecords++;

continue;

}

}

if(c == '.')

{

if(i+1 == strSalary.length()-1)

{

if(!Character.isDigit(strSalary.charAt(i)))

{

System.out.println("Char at position " + (i+1) + " in salary is not a digit");

incorrectRecords++;

continue;

}

if(!Character.isDigit(strSalary.charAt(i+1)))

{

System.out.println("Char at position " + (i+1+1) + " in salary is not a digit");

incorrectRecords++;

continue;

}

}

else

{

System.out.println("Period is in the wrong position. Expected at " + (strSalary.length()-3) + " but found at " + (i+1));

continue;

}

}

city = cityState.split(",")[0];

state = cityState.split(",")[1];

salary = Double.parseDouble(strSalary);

if(status.equals("D"))

{

bonus = salary * 0.125;

dRecords++;

pd.write(firstname + " " + lastname + " " + status + " " + salary + " " + bonus + " " + city + " " + state);

}

else

{

bonus = salary * 0.18;

fRecords++;

prf.write(firstname + " " + lastname + " " + status + " " + salary + " " + bonus + " " + city + " " + state);

}

}

}

System.out.println("No of D records : " + dRecords);

System.out.println("No of F records : " + fRecords);

System.out.println("No of incorrect records : " + incorrectRecords);

}

}

You might be interested in
Hi I don't know of yall remeber me, but I'm Jadin aka J. I am looking for my friend group, that I have missed but can't find cau
kirill [66]

Answer:

The young lady was his daughter.The shoemaker was frightened when he saw that she wants to sit near him and took his knife to frighten her and leave him alone to do his work

Explanation:

could uh name them since if i know any i would surely tryin help

7 0
2 years ago
50POINTS
maxonik [38]

Answer:

Ensure that all material and energy inputs and outputs are as inherently safe and benign as possible. Minimize the depletion of natural resources. Prevent waste. Develop and apply engineering solutions while being cognizant of local geography, aspirations, and cultures.Green engineering is the design, commercialization, and use of processes and products that minimize pollution, promote sustainability, and protect human health without sacrificing economic viability and efficiency.The goal of environmental engineering is to ensure that societal development and the use of water, land and air resources are sustainable. This goal is achieved by managing these resources so that environmental pollution and degradation is minimized.

Explanation:i helped

7 0
3 years ago
Read 2 more answers
declare integer product declare integer number product = 0 do while product &lt; 100 display ""Type your number"" input number p
Brilliant_brown [7]

Full Question

1. Correct the following code and

2. Convert the do while loop the following code to a while loop

declare integer product

declare integer number

product = 0

do while product < 100

display ""Type your number""

input number

product = number * 10

loop

display product

End While

Answer:

1. Code Correction

The errors in the code segment are:

a. The use of do while on line 4

You either use do or while product < 100

b. The use of double "" as open and end quotes for the string literal on line 5

c. The use of "loop" statement on line 7

The correction of the code segment is as follows:

declare integer product

declare integer number

product = 0

while product < 100

display "Type your number"

input number

product = number * 10

display product

End While

2. The same code segment using a do-while statement

declare integer product

declare integer number

product = 0

Do

display "Type your number"

input number

product = number * 10

display product

while product < 100

4 0
3 years ago
A hair dryer is basically a duct of constant diameter in which a few layers of electric resistors are placed. A small fan pulls
Inessa05 [86]

Answer:

the percent increase in the velocity of air is 25.65%

Explanation:

Hello!

The first thing we must consider to solve this problem is the continuity equation that states that the amount of mass flow that enters a system is the same as what should come out.

m1=m2

Now remember that mass flow is given by the product of density, cross-sectional area and velocity

(α1)(V1)(A1)=(α2)(V2)(A2)

where

α=density

V=velocity

A=area

Now we can assume that the input and output areas are equal

(α1)(V1)=(α2)(V2)

\frac{V2}{V1} =\frac{\alpha1 }{\alpha 2}

Now we can use the equation that defines the percentage of increase, in this case for speed

i=(\frac{V2}{V1} -1) 100

Now we use the equation obtained in the previous step, and replace values

i=(\frac{\alpha1 }{\alpha 2} -1) 100\\i=(\frac{1.2}{0.955} -1) 100=25.65

the percent increase in the velocity of air is 25.65%

6 0
3 years ago
Inspections may be_____ or limited to a specific area such as electrical or plumbing
Nuetrik [128]
A is the answer for the sentence
4 0
3 years ago
Other questions:
  • Use the convolutional integral to find the response of an LTI system with impulse response ℎ(????) and input x(????). Sketch the
    8·1 answer
  • Oil with a specific gravity of 0.72 is used as the indicating fluid in a manometer. If the differential pressure across the ends
    6·1 answer
  • I dont undertand this coding problem (Java):
    8·1 answer
  • Use the results of Prob. 5–82 for plane strain near the tip with u 5 0 and n 5 13. If the yieldstrength of the plate is Sy, what
    5·1 answer
  • It is desired to produce and aligned carbon fiber-epoxy matrix composite having a longitudinal tensile strength of 800 MPa. Calc
    6·1 answer
  • I am standing on the upper deck of the football stadium. I have an egg in my hand. I am going to drop it and you are going to tr
    7·1 answer
  • Calculate the volume of a hydraulic accumulator capable of delivering 5 liters of oil between 180 and 80 bar, using as a preload
    6·1 answer
  • You’re going to write a program that models the Littleton City Lotto (not a real Lotto game). The program is going to allow to u
    6·1 answer
  • Complex machines are defined by
    8·1 answer
  • True or false tensile forces are smaller in arch bridges
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!