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
Roman55 [17]
3 years ago
10

A small company is moving all its employee data to a computer. To make a smooth transition, a software program will permit the d

ata entry personnel to enter data into a file. Design a program that writes the employees.dat file. The program should accept user input until the user indicates there are no more records to write. The Employees file contains four fields (see the Input File Description). The program will use the employee ID as criteria to determine a current employee. Validate the employee ID and employee wage fields per the requirements below. You may use any of the library functions presented in Chapter 6 of the textbook to assist in validation. Your validation routines should include error messages and allow the user to correct an input error. Use an array to hold the valid ID numbers.
Input File Description:
File: employees.dat
Field Description Data Type
Employee first name String
Employee last name String
Employee ID # String
Employee Hourly Wage Real (2 decimal places)

Output Report - Printer Spacing Chart:
GTC1305 Company
Employee Report
Employee Name Identification Number Wage

XXXXXXXXXX XXXXXXX XXXXXXXXXX $Z9.99
Computers and Technology
1 answer:
Llana [10]3 years ago
7 0

Answer:

Explanation:

This program should hold three functions for easy usage. The first will be a main function, the second will be a check function, the third will be a write function.

Main function:

First task should be to create the file using different functions which ae different for every language, like in java the function FileOutputStream will be used to make the file and PrintWriter can be used to enter data into the aforementioned file.

FileOutputStream fout=new FileOutputStream("employees.dat");

PrintWriter pw=new PrintWriter(fout);

or

PrintWriter pw=new PrintWirter(new FileOutputStream(“employees.dat”));

What we will do next is to run a do while loop which asks for the employee ID. Then it checks whether the ID is valid or not using the check function. If is comes out to be valid, then we will send the id to the write function where the further details of the employee will be asked. If it comes out to be invalid, an error message is to be printed stating that the input is wrong. Finally, we will ask the number that whether they want to enter more data. This condition will be put in the while and it will terminate the loop once the user says no more data.

Check function:

We will take a flag variable throughout the function which will keep track whether the number is valid or not.

Firstly, we will check that the entered id is less than 10 characters long. If no, then change the flag variable to invalid.

There are 5 valid id numbers that an entered id number must contain. These 5 can be entered into the system as an array.

Then in a loop we will check that whether one of these exists as a substring of the entered number.

boolean check=false;  

//here check is the flag variable. If it remains false, it means that the entered ID is not valid.

if(length<=10)

           {

               String chch[]={"RE49762358","PR156125","OF45461","RE68566547","PR156984"};

               for(int i=0;(i<5)&&(!check);i++)

               {

                   int len1=chch[i].length();

                   for(int j=0;(j<=len-len1)&&(!check);j++)

                   {

                       String check12;

                       if(j+len+1==len)

                       check12=str.substring(j);

                       else

                       check12=str.substring(j,j+len1);

                       if(check12.equals(chch[i])){check=true;}

                   }

               }

           }

After the completion of loop, we can check return the flag variable to the main function.

Write function:

The print writer function written before shows it work here. First, we input the employee first name, last name and the employee hourly wage from the user. Do have a check statement for the hourly wage to be less than $45.50. If all conditions are fulfilled, then print all the details to the file.

pw.println(first_name);

pw.println(last_name);

pw.println(employee_id);

pw.println(hourly_wage);

pw.flush();            

You might be interested in
What file is being called by this IMG tag?
Triss [41]
The IMG tag is an image in an HTML page.
4 0
3 years ago
Read 2 more answers
The attribute that comes naturally to a person, such as manual dexterity, is called
Effectus [21]
The answer is Ability. 
7 0
3 years ago
Read 2 more answers
I really need To know how To get The special ending for final fight 2 for super nintendo it’s a video game
Bogdan [553]

Answer:

Check Yt

Explanation:

More often than not there are many video tutorials about every game imaginable.

5 0
3 years ago
What's the minimum storage for onedrive e2
cupoosta [38]
It should be 1 TB per user
3 0
3 years ago
As long as users refer to files in the ____ directory, they can access the files without entering the absolute filename.
algol13
Your answer to the question would be "Root"
4 0
3 years ago
Other questions:
  • Given four values representing counts of quarters, dimes, nickels and pennies, output the total amount as dollars and cents. Out
    10·1 answer
  • In a relational database design, all relationships are expressed by ________.
    10·1 answer
  • Which Supreme Court case resulted in a decree issued for the Michigan Department of Corrections to provide female inmates access
    10·1 answer
  • Universal Container sales reps can modify fields on an opportunity until it is closed. Only the sales operations team can modify
    13·1 answer
  • Joe always misspells the word calendar. He types the word as calender but the correct spelling appears on the document. Which fe
    6·1 answer
  • The goal of quality assurance is toprovide management with the data needed to determine whichsoftware engineers are producingthe
    7·1 answer
  • The ____ method returns an integer that represents the location of the substring within the string.
    13·1 answer
  • PLEASE HELP ASAP!!! 99 POINTS FOR 3 MULTIPLE CHOICE QUESTIONS!!! PLEASE ANSWER ALL!!!
    8·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    13·1 answer
  • How bridges are built over water
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!