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
_____ can be defined as the rate at which work is done or the amount of work done based on a period of time. (2 Points) voltage
Ymorist [56]

Answer: Power

Explanation:

The rate at which work is done or the amount of work done based on a period of time is referred to as power.

Power can also be defined as the amount of energy that is being transferred per unit time. The unit of power is one joule per second or simply called the watt.

4 0
3 years ago
From the article "Time Travel Is A Fun Science Fiction Story But Could It Be Real?", Albert Einstein's Theory of Relativity is d
zhannawk [14.2K]

Answer:

Option A

Explanation:

As per the article "Time Travel Is A Fun Science Fiction Story But Could It Be Real?" the gravitational field is a representation of curving space and time. As the gravity becomes strong, the space-time get more curved and hence the time gets slower.

Hence, option A is correct

8 0
3 years ago
Which of these people is an engineer?
Debora [2.8K]

Answer:

a

Explanation:

the others dont make sense to be an engineer

8 0
3 years ago
What input is required from ADC to allow the INS to calculate W/V?
Kazeer [188]

TAS is an important input which is required from ADC to allow the INS calculate W/V.

<h3>What is INS?</h3>

INS is abbreviation for Inertial Navigation System and it can be defined as a navigation device that makes use of motion sensors, a computer, and rotation sensors, so as to continuously calculate by dead reckoning the velocity, position, and orientation of a moving object.

In the Aviation and Engineering filed, True Airspeed (TAS) is an important input which is required from ADC to allow the Inertial Navigation System (INS) calculate W/V.

Read more on Inertial Navigation System here: brainly.com/question/26052911

#SPJ12

4 0
2 years ago
In an apartment the interior air temperature is 20°C and exterior air temperatures is 5°C. The wall has inner and outer surface
ELEN [110]

Answer:

20 W/m², 20 W/m², -20 W/m²

Yes, the wall is under steady-state conditions.

Explanation:

Air temperature in room = 20°C

Air temperature outside = 5°C

Wall inner temperature = 16°C

Wall outer temperature = 6°C

Inner heat transfer coefficient = 5 W/m²K

Outer heat transfer coefficient = 20 W/m²K

Heat flux = Concerned heat transfer coefficient × (Difference of the temperatures of the concerned bodies)

q = hΔT

Heat flux from the interior air to the wall = heat transfer coefficient of interior air × (Temperature difference between interior air and exterior wall)

⇒ Heat flux from the interior air to the wall = 5 (20-6) = 20 W/m²

Heat flux from the wall to the exterior air = heat transfer coefficient of exterior air × (Temperature difference between wall and exterior air)

⇒Heat flux from the wall to the exterior air = 20 (6-5) = 20 W/m²

Heat flux from the wall to the interior air = heat transfer coefficient of interior air × (Temperature difference between wall and interior air)

⇒Heat flux from the wall and interior air = 5 (16-20) = -20 W/m²

Here the magnitude of the heat flux are same so the wall is under steady-state conditions.

7 0
3 years ago
Other questions:
  • A tiny, glass sphere has a charge of +10.9 nC. A metal ball bearing, which is 4.00 cm above the glass sphere, experiences an ele
    5·1 answer
  • A stem and leaf display
    12·1 answer
  • A 450 MWt combined cycle plant has a Brayton cycle efficiency of 24% and a Rankine cycle efficiency of 29% with no heat augmenta
    6·1 answer
  • A turbine blade made of a metal alloy (k = 17 W/m·K) has a length of 5.3 cm, a perimeter of 11 cm, and a cross-sectional area of
    15·1 answer
  • A ball A is thrown vertically upward from the top of a 24-m-high building with an initial velocity of 7 m/s . At the same instan
    12·1 answer
  • Looking for new information is one reason you should do research for a speech.
    15·2 answers
  • What are the four causes of electrical faults?
    5·1 answer
  • A cylindrical 1045 steel bar is subjected to repeated compression-tension stress cycling along its axis. If the load amplitude i
    10·1 answer
  • 11) If the evaporating pressure was 76 psig for r-22and the compressor inlet temperature was 65f, what would be the total superh
    13·1 answer
  • The National Park Service is waiting on your recommendation.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!