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
Water of dynamic viscosity 1.12E-3 N*s/m2 flows in a pipe of 30 mm diameter. Calculate the largest flowrate for which laminar fl
Naya [18.7K]

Answer:

For water

Flow rate= 0.79128*10^-3 Ns

For Air

Flow rate =1.2717*10^-3 Ns

Explanation:

For the flow rate of water in pipe.

Area of the pipe= πd²/4

Diameter = 30/1000

Diameter= 0.03 m

Area= 3.14*(0.03)²/4

Area= 7.065*10^-4

Flow rate = 7.065*10^-4*1.12E-3

Flow rate= 0.79128*10^-3 Ns

For the flow rate of air in pipe.

Flow rate = 7.065*10^-4*1.8E-5

Flow rate =1.2717*10^-3 Ns

7 0
3 years ago
Lately, you have noticed some repetitive stress in your wrist. Which sign is most likely the cause of that stress and pain?
Cerrena [4.2K]
1, you might have been carrying things that are way too heavy for you.
2, you might have weak tendons.
3 0
3 years ago
A 11-cm-diameter horizontal jet of water with a velocity of 40 m/s relative to the ground strikes a flat plate that is moving in
Reika [66]

Answer:

F = 8552.7N

Explanation:

We need first our values, that are,

V_{jet} = 40m/s\\V_{Plate} = 10m/s \\D = 11cm

We start to calculate the relative velocity, that is,

V_r = V_{jet}-V_{plate}\\V_r = (40)-(10)\\V_r = 30m/s

With the relative velocity we can calculate the mass flow rate, given by,

\dot{m}_r = \rho A V_r

\dot{m}_r = (1000)(30) \frac{\pi (0.11)^2}{4}

\dot{m}_r = 285.09kg/s

We need to define the Force in the direction of the flow,

\sum\vec{F} = \sum_{out} \beta\dot{m}\vec{V} - \sum_{in} \beta\dot{m} \vec{V}\\

F = \dot{m}V_r

F = (285.09Kg/s)(30)

F = 8552.7N

8 0
3 years ago
Georgia Tech is committed to creating solutions to some of the world’s most pressing challenges. Tell us how you have improved o
Kaylis [27]

Answer:

Georgia Tech is committed to WGAR 53566 THE ANSWER IS JELLY IS KING AND THE JELLY IS KING AND  hope to improve the human condition in your community.

Explanation:

6 0
3 years ago
If a hoist lifts a 4500lb load 30ft in 15s, the power delivered to the load is a) 18.00hp b) 9000hp c) 16.36hp d) None of the ab
12345 [234]

Answer:

Explanation:

load = 4500lb                   lift height= 30 ft

time =15 s

velocity=\frac{30}{15} ft/s

velocity=2 ft/s

power = force\times velocity

power={4500}\times2

power= 9000 lb ft/s

1 hp= 550 lb ft/s

power= \frac{9000}{550} =16.36 hp

5 0
3 years ago
Other questions:
  • WILL BRAINLIEST IF CORRECT!!!!!<br><br> Some one help ASAP.
    8·1 answer
  • ______________ help protect the lower legs and feet from heat hazards like molten metal and welding sparks. A) Safety shoesB) Le
    7·1 answer
  • Two engineers are discussing the various merits of hydroelectricity. Engineer A says that tidal barrage systems can generate ele
    6·1 answer
  • which systems engineering support discipline has the goal to ensure that support considerations are an integral part of the syst
    14·1 answer
  • Determine the wattmeter reading when it is connected to resistor load.​
    11·1 answer
  • If most wildfires are suppressed (all fires are put out) for many years, how does the risk of wildfire in the area change in the
    10·1 answer
  • 1. Lea y analice la Norma ISO 16949 - Calidad en la industria automotriz, luego se ubica en los requisitos particulares, usted m
    12·1 answer
  • Advanced manufacturing does NOT serve the transportation, communications, or medical industries. Is this statement TRUE or FALSE
    11·2 answers
  • Explain your own understanding about the relevant connections between the four subsystems of Earth through the use of a creative
    9·1 answer
  • Which of following is not malicious ?<br> Worm<br> Trogan Horse<br> Driver<br> Virus
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!