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
A database planner names a field “Organic ingredients_3”. Why would this name Create possible problems in programming?
o-na [289]

Answer:

I think the answer is 2.

hope it will help you

4 0
2 years ago
Read 2 more answers
You are writing a program that defines a variable within a loop, and then tries to use that variable outside the loop. However,
Law Incorporation [45]

Answer:

The Variable is out of scope

Explanation:

In programming variables exists with scopes This could be local or global. When a variable is declared as a global variable it is available to all methods and procedures in the program. Java programming language as well as C++ and several others use the open and close braces to define the scope in programs. consider the following example

<em>public class ANot {</em>

<em>    public static void main(String[] args) {</em>

<em>        int i = 0;</em>

<em>        while ( i<10){</em>

<em>            int sum = 0;</em>

<em>            sum = sum+i;       </em>

<em>        }</em>

<em>    }</em>

<em>}</em>

In this example, the variable i is global and can be assessed within the while loop but the variable sum is local to the while loop and cannot be assessed outside of it

4 0
3 years ago
ZeroIt is a function that takes one argument and returns no value. The argument is a pointer to int. The function stores the val
Sedbober [7]

Answer:

zeroIt(&x);

Explanation:

The statement that sets the value stored in x to zero by invoking the function zerolt is given below

zeroIt(&x);

The zeroIt function is also given below for better understanding.

void zeroIt(int *x) {

   *x = 0;

}

As seen, the function takes an argument with integer variable type, which is a pointer, denoted by the asterisk symbol (*x).

The ampersan sign (&x) is used to access the variable whose value can then be stored.

7 0
3 years ago
Write a computer program that determines how many grades are between 0 and 19.
True [87]

Answer:

public class nnn {

   public static void main(String[] args) {

       int [] examScores = {31, 70, 92, 5, 47, 88, 81, 73, 51, 76, 80, 90, 55, 23, 43,98,36,87,22,61, 19,69,26,82,89,99, 71,59,49,64};

       int zeroTo19 = 0;

       int nineteenTo39 = 0;

       int fortyTo59 = 0;

       int sixtyTo79 = 0;

       int eightyTo100 = 0;

       for(int i =0; i<examScores.length; i++){

           if(examScores[i]<=19){

               zeroTo19++;

           }

           else if(examScores[i]>19&&examScores[i]<=39){

               nineteenTo39++;

           }

           else if(examScores[i]>39&&examScores[i]<=59){

               fortyTo59++;

           }

           else if(examScores[i]>59&&examScores[i]<=79){

               sixtyTo79++;

           }

           else {

               eightyTo100++;

           }

       }

       System.out.println("0 - 19 is "+zeroTo19);

       System.out.println("20 - 39 is "+nineteenTo39);

       System.out.println("40 - 59 is "+fortyTo59);

       System.out.println("60 - 79 is "+sixtyTo79);

       System.out.println("80 - 100 is "+eightyTo100);

   }

}

Explanation:

  • This has been solved with Java
  • Create an array of the exam scores
  • Create new variables for each of the score range
  • Use multiple if statements as u loop through the array to determine the range of scores
  • Finally outside the loop print them variables out
7 0
2 years ago
Calculate the weighted grade for each student that appears in the data file. You may calculate the grade based on total earned p
lutik1710 [3]

Answer:

I don't know the answer, sorry

6 0
3 years ago
Other questions:
  • Background Susan finished work on system architecture issues, and her system design specification was approved. Now she is ready
    15·1 answer
  • What type of Windows Server is the most likely server to be targeted by a computer hacker?
    13·2 answers
  • All languages from the second generation on must be translated into machine language for the computer to be able process the inp
    8·1 answer
  • Anna is making a presentation on the solar system. She wants to emphasize the planet names as they appear one by one on the pres
    11·1 answer
  • Ternary operators of computer<br><br>please explain. ​
    15·1 answer
  • What allows you to heal<br><br><br><br> undesirable portions of an image​
    9·1 answer
  • Five advantages of Internet​
    6·2 answers
  • • Comments are blank which can be blank entered into documents
    5·1 answer
  • What is file management?can please help me​
    14·2 answers
  • Exam Instructions
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!