Question

Using c++ write a program using a class that has   data members ID#,NAME, SALARY, YEAR_HIRED. This...

Using c++ write a program using a class that has   data members ID#,NAME, SALARY, YEAR_HIRED. This program must

1) write 10 blank records to a random access file. You must enter data for 4 of these records.

2) allow the user to output the name, salary, hire_date for a selected record

3) allow the user to change the name, salary, or hire_date for a selected record.

4) allow the user to input a complete record to replace one of the blank records.

Note: The record number is the ID number. This should be 1 - 10.

~ First write a program that writes a name to a random access file and reads it.

~Then make NAME, SALARY, YEAR_HIRED arrays.

~Then make the program write and read 4 records and 6 blank records.

~Lastly allow user to output and modify selected record.

Submission must compile and must be able to write and read from a random access (binary) file.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
struct student
{
int id;
char name[30];
int salary;
int year_hired;

};
struct student stud[10];
int i,n,ID,new_id,new_salary,new_year;
char new_name[30];
stud[0].id=1;
strcpy(stud[0].name,"rashi");
stud[0].salary=1200;
stud[0].year_hired=2000;
stud[1].id=2;
strcpy(stud[1].name,"tripura");
stud[1].salary=1500;
stud[1].year_hired=2001;
stud[2].id=3;
strcpy(stud[2].name,"lavanya");
stud[2].salary=1000;
stud[2].year_hired=2006;
stud[3].id=4;
strcpy(stud[3].name,"pavani");
stud[3].salary=1700;
stud[3].year_hired=2002;
printf("\n enter the record no. which you to display:");
scanf("%d",&n);
printf("\n ID no.=%d",stud[n].id);
printf("\n name=%s",stud[n].name);
printf("\n salary=%d",stud[n].salary);
printf("\n year_hired=%d",stud[n].year_hired);
printf("\n enter the id no. of student whose record has to be edited:");
scanf("%d",&ID);
printf("\n enter the new id number:");
scanf("%d",&new_id);
printf("\n enter the new name:");
scanf("%s",&new_name);
printf("\n enter the new salary:");
scanf("%d",&new_salary);
printf("\n enter the new year:");
scanf("%d",&new_year);
stud[ID].id=new_id;
strcpy(stud[ID].name,new_name);
stud[ID].salary=new_salary;
stud[ID].year_hired=new_year;
printf("\n modified results");
printf("\n ID no.=%d",stud[ID].id);
printf("\n name=%s",stud[ID].name);
printf("\n salary=%d",stud[ID].salary);
printf("\n year_hired=%d",stud[ID].year_hired);

return 0;

}

Add a comment
Know the answer?
Add Answer to:
Using c++ write a program using a class that has   data members ID#,NAME, SALARY, YEAR_HIRED. This...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Implement Random Access Binary Files. Do Not use Arrays instead write the data directly to...

    C++ Implement Random Access Binary Files. Do Not use Arrays instead write the data directly to Random Access Binary File. New program should be modified to display a menu for the user to do the following: 1. Replace Employee and Department classes with Employee and Department Structures. 2. Inside each structure, replace all string variables with array of characters. 3. Make Employee and Department editable. That means, the user should be able to edit a given Employee and Department. 4....

  • C++ Implement Random Access Binary Files. Do Not use Arrays instead write the data directly to...

    C++ Implement Random Access Binary Files. Do Not use Arrays instead write the data directly to Random Access Binary File. New program should be modified to display a menu for the user to do the following: 1. Replace Employee and Department classes with Employee and Department Structures. 2. Inside each structure, replace all string variables with array of characters. 3. Make Employee and Department editable. That means, the user should be able to edit a given Employee and Department. 4....

  • project-8c Write a class named Employee that has data members for an employee's name, ID_number, salary,...

    project-8c Write a class named Employee that has data members for an employee's name, ID_number, salary, and email_address (you must use those names - don't make them private). Write a function named make_employee_dict that takes as parameters a list of names, a list of ID numbers, a list of salaries and a list of email addresses (which are all the same length). The function should take the first value of each list and use them to create an Employee object....

  • The name of the C++ file must be search.cpp Write a program that will read data...

    The name of the C++ file must be search.cpp Write a program that will read data from a file. The program will allow the user to specify the filename. Use a loop that will check if the file is opened correctly, otherwise display an error message and allow the user to re-enter a filename until successful. Read the values from the file and store into an integer array. The program should then prompt the user for an integer which will...

  • Write a program that would ask the user to enter an input file name, and an...

    Write a program that would ask the user to enter an input file name, and an output file name. Then the program reads the content of the input file, and read the data in each line as a number (double). These numbers represent the temperatures degrees in Fahrenheit for each day. The program should convert the temperature degrees to Celsius and then writes the numbers to the output file, with the number of day added to the beginning of the...

  • Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a...

    Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a main function and three other functions called. readmarks , changemarks (, and writemarks() The program begins by calling the function readmarks () to read the input file marksin. txt which consists of a series of lines containing a student ID number (an integer) and a numeric mark (a float). Once the ID numbers and marks have been read into arrays (by readmarks () the...

  • Write a C++ menu driven Payroll program. Must be user friendly.   Menu 1. Check data file  ...

    Write a C++ menu driven Payroll program. Must be user friendly.   Menu 1. Check data file   2. Read Data file 3. Process payroll for one employee 4. Process payroll for all employees 5. Print out to a text or an HTML file 6. Exit You must use the following Payroll classes, structures, pointers, arrays, enum, vector, recursive, advance file I/O, STL, iterators and containers. The program to process an input file below to calculate tax of 28% and output it...

  • C++ program: Write an address book program that will accomplish the following: 1. Read name and...

    C++ program: Write an address book program that will accomplish the following: 1. Read name and address data from the user from the keyboard. 2. While reading the names and addresses, put the names into an appropriate data structure. 3. After reading names and addresses, allow user to search for names and change the names or addresses in the container data structure. 4. Allow user to write out the container data structure to a comma delimited file. The input file...

  • In C++ write a simple menu program that displays a menu for the user in an...

    In C++ write a simple menu program that displays a menu for the user in an object-oriented technique. The menu should keep showing up until the user chooses to quit. Also, there is a sub-menu inside a menu. The user should get at least a line displayed after he or she chooses that particular option meaning if the user presses 1 for the read actors from the file. The output can look like "reading actors from a file" and then...

  • please write in C++ Write a program that uses a structure to store the following inventory...

    please write in C++ Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or the keyboard Item name (string) Quantity on hand(int) Wholesale cost(double) Retail Cost(double) The program should have a menu that allows the user to perform the following tasks: Add new records to the file Display any record in the file User will provide the name of the item or the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT