Question

First program: Name of the program must be WritingToIO; The program uses two variables named emplNum...

  1. First program:
    • Name of the program must be WritingToIO;
    • The program uses two variables named emplNum and salary;
    • The program must be able to accept values for each of the variables and save the information to a file called SalariesData.txt.
  2. Second program:
    • Name of the program must be ReadingFromIO;
    • This program must ensure the information/ values can be retrieved from the file SalariesData.txt referred to in Step 1a above (i.e. the file where the employee salary data was written to).
    • First program:
    • Name of the program must be WritingToIO;
    • The program uses two variables named emplNum and salary;
    • The program must be able to accept values for each of the variables and save the information to a file called SalariesData.txt.
    • Second program:
    • Name of the program must be ReadingFromIO;
    • This program must ensure the information/ values can be retrieved from the file SalariesData.txt referred to in Step 1a above (i.e. the file where the employee salary data was written to).

Homework Answers

Answer #1

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

class WritingToIO

{

public static void main(String[] args)

{

try

{ File myObj = new File("SalariesData.txt");

Scanner myReader = new Scanner(myObj);

while (myReader.hasNextLine())

{ int emplNum = myReader.nextInt();

System.out.println("enter the employee number");

int salary= myReader.nextInt();

System.out.println("enter the employee salary");

}

myReader.close();

} catch (FileNotFoundException e)

{ System.out.println("An error occurred.");

e.printStackTrace();

} } }

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a class called Employee that contains three instance variables (First Name (String), Last Name (String),...
Create a class called Employee that contains three instance variables (First Name (String), Last Name (String), Monthly Salary (double)). Create a constructor that initializes these variables. Define set and get methods for each variable. If the monthly salary is not positive, do not set the salary. Create a separate test class called EmployeeTest that will use the Employee class. By running this class, create two employees (Employee object) and print the annual salary of each employee (object). Then set the...
Goals: Write a program that uses binary files. Write a program that stores records to a...
Goals: Write a program that uses binary files. Write a program that stores records to a binary file. C++ Requirements: Write a program that includes a structure named Part that contains the following fields: name - a character array of 20 elements that stores the name of the part. qty - an integer that stores the number of parts in stock. price - a double that stores the price of the part. Create three Part variables in main, and fill...
C Programming: Create a struct named “Student” along with 3 properties, Name, ID, Score Choosing the...
C Programming: Create a struct named “Student” along with 3 properties, Name, ID, Score Choosing the correct data type for each property. Once the program is running, it will check if the student.bin file is exist and if it is not exist, the program will ask user to enter three student information and save them to file student.bin . If the file is exist, read the second student information and print it in console.
This program is in C++: Write a program to allow the user to: 1. Create two...
This program is in C++: Write a program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
In this lab, you complete a partially prewritten C++ program that uses an array. The program...
In this lab, you complete a partially prewritten C++ program that uses an array. The program prompts the user to interactively enter eight batting averages, which the program stores in an array. The program should then find the minimum and maximum batting average stored in the array as well as the average of the eight batting averages. The data file provided for this lab includes the input statement and some variable declarations. Comments are included in the file to help...
Using C# Create an Employee class with five fields: first name, last name, workID, yearStartedWked, and...
Using C# Create an Employee class with five fields: first name, last name, workID, yearStartedWked, and initSalary. It includes constructor(s) and properties to initialize values for all fields. Create an interface, SalaryCalculate, class that includes two functions: first,CalcYearWorked() function, it takes one parameter (currentyear) and calculates the number of year the worker has been working. The second function, CalcCurSalary() function that calculates the current year salary. Create a Worker classes that is derived from Employee and SalaryCalculate class. In Worker...
In JAVA write the following program: Objective: Practice object-oriented principles by making two Peanut Butter and...
In JAVA write the following program: Objective: Practice object-oriented principles by making two Peanut Butter and Jelly Sandwiches. The program must create two sandwiches based on user input. The sandwich information for both must then print out their details and determine if the two sandwiches are equal. Requirements: Write a class called Bread with the following Instance Variables Name: The name brand of the bread. o   Calories: The number of calories per slice assumed to be between 50 and 250 inclusively....
Could you script in Matlab : Script Name General Algorithm AddNewEmployee Display all of the ID...
Could you script in Matlab : Script Name General Algorithm AddNewEmployee Display all of the ID numbers currently in use Read in a new ID number If the ID number read in is already in use Report this fact End this script Else (this is a new ID number) Read in: Years with the company Salary Vacation days Sick days Add this new employee to the database (by appending a new row to the end of the EmployeeData matrix) Note...
Program Behavior Each time your program is run, it will prompt the user to enter the...
Program Behavior Each time your program is run, it will prompt the user to enter the name of an input file to analyze. It will then read and analyze the contents of the input file, then print the results. Here is a sample run of the program. User input is shown in red. Let's analyze some text! Enter file name: sample.txt Number of lines: 21 Number of words: 184 Number of long words: 49 Number of sentences: 14 Number of...