Related questions
Using the data file capabilities of C++, create a Personnel file, personnel.dat on your drive and the C++ program that will write employee data to that file. Your file will contain six employees:
Last Name: Jones Kirk McCoy Doe Boop Rabbitt
First Name: Davy James Leonard Jayne Betty Jessica
Worker ID: D1234 K2231 M1856 D0104 B2525 R0331
Hours: 20.5 40 45 25.5 40 40
Pay Rate: 10ドル.25 15ドル.50 20ドル.97 10ドル.00 16ドル.00 15ドル.00
Tax Rate: 0.05 0.25 0.3 0.05 0.10 0.3
Each employee's record should also include three MORE fields for:
Gross Pay = Hours X Pay Rate
Taxes = Gross Pay * Tax Rate
Net Pay = Gross Pay - (Gross Pay X Tax Rate)
This assignment will have two parts:
1) Entering, writing, records into the file.
The logic should allow the user to enter as many records as they wish, compute Gross Pay and Net Pay. Write the data to the data file, Personnl.Dat. Put a single blank between each data field to act as a default delimiter.
2) Reading records from the file and printing them on the screen.
Retrieve each record. Read a record and check for the EOF. Since you really don't know how many records are in the data file, use a while loop. The loop will read the record at the end of the loop.
Be sure to format appropriate values as currency. See if you can format the hours as decimal with 1 decimal position (i.e. 40 hours as 40.0 hours). Use a While loop around the main logic to let the user keep adding or reading instead of one pass through the entire program logic.
One combined program.....the application must allow the user to switch between writing records and reading them (write two separate programs and your grade "suffers").
Display your employee output as an "itemized display". Present a "menu" as an interface to the user.
Enter an Option
1 - Write new Records to the Data file
2 - Display Records From the Data file to the Screen
3 - Find ALL Records with a Pay Rate Less than $ "N" Dollars Per Hour
4 - QUIT
Enter Your option: 2
Output Example (reading the file’s records):
Record #1
Employee ID: AD2201
Last Name: Pokemon First Name: Pikachu
Hours Worked: 40.00 Pay Per Hour: 12ドル.34 Gross Pay: 493ドル.60
Taxes: 14ドル.81 Net Pay: 478ドル.79
Employee Tax Rate: 3.00%
Record #2
Employee ID: AF0091
Last Name: Pokemon First Name: Squirtel
Hours Worked: 35.67 Pay Per Hour: 23ドル.54 Gross Pay: 839ドル.67
Taxes: 25ドル.19 Net Pay: 814ドル.48
Employee Tax Rate: 3.00%
Record #3
Employee ID: AS2333
Last Name: Tralfaz First Name: Henri
Hours Worked: 34.50 Pay Per Hour: 23ドル.45 Gross Pay: 809ドル.03
Taxes: 161ドル.81 Net Pay: 647ドル.22
Employee Tax Rate: 20.00%
Your data file opened under an ASCII editor such as Notepad should appear in a configuration like:
AD2201 Pokemon Pikachu 40.00 12.34 493.60 14.81 14.81 463.98 0.03 0.03
AF0091 Pokemon Squirtel 35.67 23.54 839.67 25.19 33.59 780.89 0.03 0.04
AS2333 Tralfaz Henri 34.50 23.45 809.03 161.81 242.71 404.51 0.20 0.30
DA1120 Pokemon Pikachu 40.00 12.35 494.00 14.82 12.35 466.83 0.03 0.03
DC2231 Pokemon Balbasaur 33.50 12.34 413.39 8.27 4.13 400.99 0.02 0.01
Enter an Option
1 - Write new Records to the Data file
2 - Display Records From the Data file to the Screen
3 - Find ALL Records with a Pay Rate Less than $ "N" Dollars Per Hour
4 - QUIT
Enter Your option: 3
Finding ALL Employees with Pay Rates Less than $ "N" Per Hour
Enter the Pay Rate Amount to Find All Employees have a Pay Rate "Less" than: 15.75
Record #1
Employee ID: AD220
Last Name: Pokemon First Name: Pikachu
Hours Worked: 40.00 Pay Per Hour: 12ドル.34 Gross Pay: 493ドル.60
Federal Taxes: 14ドル.81 State Taxes 14ドル.81 Net Pay: 463ドル.98
Employee Federal Tax Rate: 3.00% Employee State Tax Rate: 3.00%
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps
- In C++ Write a code snippet to automatically increase the size of the dynamic array prayerBox[10] if it becomes full while reading data in from a file.arrow_forwardC++ Write a code segment that creates an ofstream object named outfile, opens a file named numfile.txt, and associates it with outfile. Then write the contents of the variable data to the file, followed by a newline, then close the file.arrow_forwardGDB and Getopt Class Activity activity [-r] -b bval value Required Modify the activity program from last week with the usage shown. The value for bval is required to be an integer as is the value at the end. In addition, there should only be one value. Since everything on the command line is read in as a string, these now need to be converted to numbers. You can use the function atoi() to do that conversion. You can do the conversion in the switch or you can do it at the end of the program. The number coming in as bval and the value should be added together to get a total. That should be the only value printed out at the end. Total = x should be the only output from the program upon success. Remove all the other print statements after testing is complete. Take a screenshot of the output to paste into a Word document and submit. Practice Compile the program with the -g option to load the symbol table. Run the program using gdb and use watch on the result so the program stops when the...arrow_forward
- each line in the input file will represent a record of data. There will be 10 lines, thus 10 records. Each record (line) will consist of 3 space separated fields: a name (1 word as a string), and age (as an integer), and a wage (as a float). Write a C program that: takes an input file name from the command line; opens that file if possible; declares a C struct with three variables; these will have data types that correspond to the data types read from the file (i.e. string, int, float); declares an array of C structs (i.e. the same struct type declared in point c); reads a record from the file and stores the values read into the appropriate struct variable at the appropriate array index (for that record); continues reading each record into a struct (as in point 1e), and stores each struct containing the 3 values into the array of structs declared in point d; closes the file when all records have been read. should print an error message in the event that the file cannot be...arrow_forwardThe international Olympics Committee has asked you to write a program to process their data and determine the medal winners for the pairs figure skating. You will be given a file named Pairs.txt.This file contains the data for each pair of skaters. The data consists of each skater’s name, their country and the score from each of eight judges on the technical aspects and on the performance aspects. A typical record in the file would be as follows: SmithJonesAustralia5.0 4.9 5.1 5.2 5.0 5.1 5.2 4.84.3 4.7 4.8 4.9 4.6 4.8 4.9 4.5 LennonMurrayEngland2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.83.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8GustoPetitotItalia4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.85.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8LahaiePetitFrance1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.85.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8BilodeauBernardCanada2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.84.1 4.2 4.3 4.8 4.9 4.6 4.0 4.5LahorePedroMexico3.2 3.1 3.8 3.9 3.0 3.6 3.9 3.35.9 5.8 5.8 5.8 5.9 5.6 5.0 5.5MaliakKolikovRussia4.2 4.1 4.8 4.9 4.0 4.6 4.9 4.31.9 1.8 1.8 1.8...arrow_forwardIn C write a program that takes a file name and two strings as command line arguments, and writes the longer of the two strings to the file with the given name. If the given strings are the same length, write the first string given to the file. If the user does not provide the correct number of command line arguments, print an error message and exit the program with a non-zero exit code.arrow_forward
- C++ Write a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at most 20. Assume also the last names and first names do not contain whitespaces. The program performs the following tasks: Read the file name of the tsv file from the user. Open the tsv file and read the student information. Compute the average exam score of each student. Assign a letter grade to each student based on the average exam score in the following scale: A: 90 =< x B: 80 =< x < 90 C: 70 =< x < 80 D: 60 =< x < 70 F: x < 60 Compute the average of each exam. Output the last names, first names, exam scores, and letter grades of the...arrow_forwardwrite in c++Write a program that would allow the user to interact with a part of the IMDB movie database. Each movie has a unique ID, name, release date, and user rating. You're given a file containing this information (see movies.txt in "Additional files" section). The first 4 rows of this file correspond to the first movie, then after an empty line 4 rows contain information about the second movie and so forth. Format of these fields: ID is an integer Name is a string that can contain spaces Release date is a string in yyyy/mm/dd format Rating is a fractional number The number of movies is not provided and does not need to be computed. But the file can't contain more than 100 movies. Then, it should offer the user a menu with the following options: Display movies sorted by id Display movies sorted by release date, then rating Lookup a release date given a name Lookup a movie by id Quit the Program The program should perform the selected operation and then re-display the menu. For...arrow_forwardHello, I am working in java and wondering why my program isn't working. I will attach the criteria and code below. I have attached my error. Criteria ------------ Inventory Update program. The first set of records is the master file which reflects an item inventory at the start of the business day. Each master file record contains a part number and a corresponding item stock quantity. Let us assume that the master file contains no more than 5 records. The second set of records reflects the transactions for each of various items during that day. Transaction records contain have the same format as the master file records: they contain the item number and the corresponding total number of items sold that day. There is unknown number of such transaction records in the input file. Write a program to update the master file against the transaction file to produce the new master file at the end of the day. A record notice should accompany any item number for which fewer than 10 items remain...arrow_forward
- Write a menu-driven C++ program to manage your college course history and plans, named as you wish. It should work something like this: Array size: 0, capacity: 2MENUA Add a courseL List all coursesC Arrange by courseY arrange by YearU arrange by UnitsG arrange by GradeQ Quit...your choice: a[ENTER]Enter a courses' name: Comsc-165[ENTER]Enter the year for Comsc-165 [like 2020]: 2016[ENTER]Enter the units for Comsc-165 [0, 1, 2,...]: 4[ENTER]Enter the grade for Comsc-165 [A, B,..., X if still in progress or planned]: x[ENTER]Array size: 1, capacity: 2MENUA Add a courseL List all coursesC Arrange by courseY arrange by YearU arrange by UnitsG arrange by GradeQ Quit...your choice: a[ENTER]Enter a courses' name: Comsc-110[ENTER]Enter the year for Comsc-110 [like 2020]: 2015[ENTER]Enter the units for Comsc-110 [0, 1, 2,...]: 4[ENTER]Enter the grade for Comsc-110 [A, B,..., X if still in progress or planned]: A[ENTER]Array size: 2, capacity: 2MENUA Add a courseL List all coursesC Arrange by...arrow_forwardFirst programming homework Create a class of records for a gradebook called Rec. The data should be private, and should include a firstname, lastname, array of three grades, and a field for average grade. Build two constructors: a default constructor and a constructor that takes the first and last name. Build a function to read the data, either from a file or from cin. The read function reads the two names and three grades, but does not read the average grade. Build a write function that writes the data either to a file or to cout. The write function prints all of the data on one line with spaces between fields. Build a function to calculate the average grade field. Build an overloaded operator == to compare two records. This should be implemented as a friend function. Declare the constructors and functions in the body of the class, but implement them outside the class. I will provide you with a driver called hw1.cpp in ~cthorpe/public/142 and with a test file HW1.txt in the same...arrow_forwardIn c++ Create a new project named lab9_2. You will continue to use the Courses class, but this time you will create a vector of Courses. The file you will read from is below: 6CSS 2A 1111 35CSS 2A 2222 20CSS 1 3333 40CSS 1 4444 33CSS 3 5555 15CSS 44 6666 12 Read this information into a vector of Courses. Then, print out a summary of your vector. Here's a sample driver: #include <iostream>#include <string>#include <fstream>#include <vector>#include <cstdlib>#include "Course.h"using namespace std;int main(){vector<Course> myclass;string dep, c_num;int classes, sec, num_stus;ifstream fin("sample.txt");if (fin.fail()){cout << "File path is bad\n";exit(1);}fin >> classes;for (int i = 0; i < classes; i++){fin >> dep >> c_num >> sec >> num_stus;// Now how do you create a Course object// that contains the information you just read in// and add it to your myclass vector?}cout << "Here are the college courses: "...arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education