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
In normal operation, a paper mill generates excess steam at 20 bar and 400◦C. It is planned to use this steam as the feed to a t
Keith_Richards [23]

Answer:

The maximum power that can be generated is 127.788 kW

Explanation:

Using the steam table

Enthalpy at 20 bar = 2799 kJ/kg

Enthalpy at 2 bar = 2707 kJ/kg

Change in enthalpy = 2799 - 2707 = 92 kJ/kg

Mass flow rate of steam = 5000 kg/hr = 5000 kJ/hr × 1 hr/3600 s = 1.389 kg/s

Maximum power generated = change in enthalpy × mass flow rate = 92 kJ/kg × 1.389 kg/s = 127.788 kJ/s = 127.788 kW

6 0
3 years ago
A 150 MVA, 24 kV, 123% three-phase synchronous generator supplies a large network. The network voltage is 27 kV. The phase angle
Aleks04 [339]

Answer:

the generator induced voltage is 60.59 kV

Explanation:

Given:

S = 150 MVA

Vline = 24 kV = 24000 V

X_{s} =1.23(\frac{V_{line}^{2}  }{s} )=1.23\frac{24000^{2} }{1500} =4723.2 ohms

the network voltage phase is

V_{phase} =\frac{V_{nline} }{\sqrt{3} } =\frac{27}{\sqrt{3} } =15.58kV

the power transmitted is equal to:

|E|=\frac{P*X_{s} }{3*|V_{phase}|sinO } ;if-O=60\\|E|=\frac{300*4.723}{3*15.58*sin60} =34.98kV

the line induced voltage is

|E_{line} |=\sqrt{3} *|E|=\sqrt{3} *34.98=60.59kV

7 0
3 years ago
The 30-kg gear is subjected to a force of P=(20t)N where t is in seconds. Determine the angular velocity of the gear at t=4s sta
tatyana61 [14]

Answer:

\omega =\frac{24}{1.14375}=20.983\frac{rad}{s}

Explanation:

Previous concepts

Angular momentum. If we consider a particle of mass m, with velocity v, moving under the influence of a force F. The angular  momentum about point O is defined as the “moment” of the particle’s linear momentum, L, about O. And the correct formula is:

H_o =r x mv=rxL

Applying Newton’s second law to the right hand side of the above equation, we have that r ×ma = r ×F =

MO, where MO is the moment of the force F about point O. The equation expressing the rate of change  of angular momentum is this one:

MO = H˙ O

Principle of Angular Impulse and Momentum

The equation MO = H˙ O gives us the instantaneous relation between the moment and the time rate of change of angular  momentum. Imagine now that the force considered acts on a particle between time t1 and time t2. The equation MO = H˙ O can then be integrated in time to obtain this:

\int_{t_1}^{t_2}M_O dt = \int_{t_1}^{t_2}H_O dt=H_0t2 -H_0t1

Solution to the problem

For this case we can use the principle of angular impulse and momentum that states "The mass moment of inertia of a gear about its mass center is I_o =mK^2_o =30kg(0.125m)^2 =0.46875 kgm^2".

If we analyze the staritning point we see that the initial velocity can be founded like this:

v_o =\omega r_{OIC}=\omega (0.15m)

And if we look the figure attached we can use the point A as a reference to calculate the angular impulse and momentum equation, like this:

H_Ai +\sum \int_{t_i}^{t_f} M_A dt =H_Af

0+\sum \int_{0}^{4} 20t (0.15m) dt =0.46875 \omega + 30kg[\omega(0.15m)](0.15m)

And if we integrate the left part and we simplify the right part we have

1.5(4^2)-1.5(0^2) = 0.46875\omega +0.675\omega=1.14375\omega

And if we solve for \omega we got:

\omega =\frac{24}{1.14375}=20.983\frac{rad}{s}

8 0
3 years ago
Determine the output logic-levels(boolean-levels) for XNOR if the two-inputs are inverted?​
stiv31 [10]

Answer:

<em><u>1</u></em>

<em><u>1What is the output of 2 Input XNOR gate if both the inputs are same? Explanation: The output of 2 Input XNOR gate is 1 if both the inputs are same. The output of the XNOR gate is 1 if both the inputs are logic 0 or logic 1. This is why they are called as equality detector.</u></em>

4 0
2 years ago
A steel bar 100 mm (4.0 in.) long and having a square cross section 20 mm (0.8 in.) on an edge is pulled intension with a load o
grigory [225]

Answer:

The elastic modulus of the steel is 139062.5 N/in^2

Explanation:

Elastic modulus = stress ÷ strain

Load = 89,000 N

Area of square cross section of the steel bar = (0.8 in)^2 = 0.64 in^2

Stress = load/area = 89,000/0.64 = 139.0625 N/in^2

Length of steel bar = 4 in

Extension = 4×10^-3 in

Strain = extension/length = 4×10^-3/4 = 1×10^-3

Elastic modulus = 139.0625 N/in^2 ÷ 1×10^-3 = 139062.5 N/in^2

7 0
3 years ago
Other questions:
  • A student is using a 12.9 ft ramp to raise an object 6 ft above the ground.
    5·1 answer
  • A manager has a list of items that have been sorted according to an item ID. Some of them are duplicates. She wants to add a cod
    7·1 answer
  • An AX ceramic compound has the rock salt crystal structure. If the radii of the A and X ions are 0.137 and 0.241 nm, respectivel
    10·1 answer
  • A three-phase transformer bank consists of 3 single-phase transformers to handle 400 kVA witha 34.5kV/13.8kV voltage ratio. Find
    7·1 answer
  • Water flows with a velocity of 3 m/s in a rectangular channel 3 m wide at a depth of 3 m. What is the change in depth and in wat
    9·1 answer
  • The price of a single item within a group of items is
    8·1 answer
  • Calculate the number of vacancies per cubic meter for some metal, M, at 749°C. The energy for vacancy formation is 0.86 eV/atom,
    5·1 answer
  • Make a sketch of a simple mechanically expanded brake and indicate the forces ​ ​ acting on the leading shoe when the brake is a
    10·1 answer
  • ?Why the efficiency of Class A amplifier is very poor​
    11·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!