Ideas Solution 2:
#include<iostream> #include<fstream> #include<stdio.h> using namespace std; class Employee{ private: int code; char name[20]; float salary; public: void read(); void display(); int getEmpCode() { return code;} int getSalary() { return salary;} void updateSalary(float s) { salary=s;} }; void Employee::read(){ cout<<"Enter employee code: "; cin>>code; cout<<"Enter name: "; cin.ignore(1); cin.getline(name,20); cout<<"Enter salary: "; cin>>salary; } void Employee::display() { cout<<code<<" "<<name<<"\t"<<salary<<endl; } fstream file; void deleteExistingFile(){ remove("EMPLOYEE.DAT"); } void appendToFille(){ Employee x; x.read(); file.open("EMPLOYEE.DAT",ios::binary|ios::app); if(!file){ cout<<"ERROR IN CREATING FILE\n"; return; } file.write((char*)&x,sizeof(x)); file.close(); cout<<"Record added sucessfully.\n"; } void displayAll(){ Employee x; file.open("EMPLOYEE.DAT",ios::binary|ios::in); if(!file){ cout<<"ERROR IN OPENING FILE \n"; return; } while(file){ if(file.read((char*)&x,sizeof(x))) if(x.getSalary()>=10000 && x.getSalary()<=20000) x.display(); } file.close(); } void searchForRecord(){ Employee x; int c; int isFound=0; cout<<"Enter employee code: "; cin>>c; file.open("EMPLOYEE.DAT",ios::binary|ios::in); if(!file){ cout<<"ERROR IN OPENING FILE \n"; return; } while(file){ if(file.read((char*)&x,sizeof(x))){ if(x.getEmpCode()==c){ cout<<"RECORD FOUND\n"; x.display(); isFound=1; break; } } } if(isFound==0){ cout<<"Record not found!!!\n"; } file.close(); } void increaseSalary(){ Employee x; int c; int isFound=0; float sal; cout<<"enter employee code \n"; cin>>c; file.open("EMPLOYEE.DAT",ios::binary|ios::in); if(!file){ cout<<"ERROR IN OPENING FILE \n"; return; } while(file){ if(file.read((char*)&x,sizeof(x))){ if(x.getEmpCode()==c){ cout<<"Salary hike? "; cin>>sal; x.updateSalary(x.getSalary()+sal); isFound=1; break; } } } if(isFound==0){ cout<<"Record not found!!!\n"; } file.close(); cout<<"Salary updated successfully."<<endl; } void insertRecord(){ Employee x; Employee newEmp; newEmp.read(); fstream fin; file.open("EMPLOYEE.DAT",ios::binary|ios::in); fin.open("TEMP.DAT",ios::binary|ios::out); if(!file){ cout<<"Error in opening EMPLOYEE.DAT file!!!\n"; return; } if(!fin){ cout<<"Error in opening TEMP.DAT file!!!\n"; return; } while(file){ if(file.read((char*)&x,sizeof(x))){ if(x.getEmpCode()>newEmp.getEmpCode()){ fin.write((char*)&newEmp, sizeof(newEmp)); } fin.write((char*)&x, sizeof(x)); } } fin.close(); file.close(); rename("TEMP.DAT","EMPLOYEE.DAT"); remove("TEMP.DAT"); cout<<"Record inserted successfully."<<endl; } int main() { char ch; deleteExistingFile(); do{ int n; cout<<"ENTER CHOICE\n"<<"1.ADD AN EMPLOYEE\n"<<"2.DISPLAY\n"<<"3.SEARCH\n"<<"4.INCREASE SALARY\n"<<"5.INSERT RECORD\n"; cout<<"Make a choice: "; cin>>n; switch(n){ case 1: appendToFille(); break; case 2 : displayAll(); break; case 3: searchForRecord(); break; case 4: increaseSalary(); break; case 5: insertRecord(); break; default : cout<<"Invalid Choice\n"; } cout<<"Do you want to continue ? : "; cin>>ch; }while(ch=='Y'||ch=='y'); return 0; }ENG503 GDB 1 Solution and Discussion
-
Total Marks 5
Starting Date Monday, January 13, 2020
Closing Date Tuesday, January 14, 2020
Status Open
Question Title Graded Discussion Board
Question DescriptionGraded Discussion Board (GDB)
Graded Discussion Board for Introduction to ELT (ENG503) will be opened from January 13, 2020 to January 14, 2020.
Give your views on ONE of the given topics. The topics for the GDB are:
- As a student of virtual mode of education, do you believe that language skills like listening and speaking can be assessed virtually? If yes, then how? Elaborate your response with genuine reasoning.
OR
- Can a person learn to speak a foreign language fluently if she/he does not know her/his mother tongue perfectly? Give genuine opinion on the topic.
Read the following instructions carefully before posting your comments:
-
Write your own views about the topic. Your comments should NOT exceed 150-250 words.
-
GDB carries 2% weightage in your final assessment.
-
Your comments should be clear, concise, and relevant to the topic.
-
Creative and original ideas written in correct English will be highly appreciated.
-
Any queries related to Graded Discussion Board (GDB) will not be entertained on Regular MDB.
-
For questions or queries related to the topic, you may send email to [email protected].
-
Do not send your comments via e-mail or regular MDB.
-
The comments posted on regular MDB will not be graded.
-
Do not post your comments twice.
-
No marks will be awarded for plagiarism.
Best of luck!
-


100% Off on Your FEE Join US! Ask Me How?


