Last active
August 29, 2015 14:17
-
-
Save krysseltillada/e7803346008e704be4b8 to your computer and use it in GitHub Desktop.
employee data info storing program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// just a small exercise program in c++ book that i study so if anyone encounters the same problem this | |
| /// this program i created will do its job according to the problem | |
| /// expect that when to input a invalid number the program will have infinite loop | |
| #include <iostream> | |
| #include <string> | |
| using namespace std; | |
| class Employee | |
| { | |
| private: | |
| int idnumber; | |
| double payrate; | |
| double numberofhours; | |
| public: | |
| Employee(int = 0, double = 0.0, double = 0); | |
| void Delval(); | |
| void Employeeinfo(); | |
| void Setinfo(); | |
| void Deleteinfo(); | |
| int Mainmenu(); | |
| }; | |
| Employee::Employee(int idnum, double pr, double noh) | |
| { | |
| idnumber = idnum; | |
| payrate = pr; | |
| numberofhours = noh; | |
| } | |
| void Employee::Employeeinfo() | |
| { | |
| cout << "\nid number: " << idnumber | |
| << "\npay rate: " << payrate | |
| << "\nnumber of hours worked: " << numberofhours << endl; | |
| return; | |
| } | |
| void Employee::Setinfo() | |
| { | |
| cout << "\nid number: "; | |
| cin >> idnumber; | |
| cout << "\npay rate: "; | |
| cin >> payrate; | |
| cout << "\nnumber of hours worked: "; | |
| cin >> numberofhours; | |
| cout << "\nregistering..... \n"; | |
| return; | |
| } | |
| void Employee::Deleteinfo() | |
| { | |
| char key; | |
| cout << "\ndelete this employee?: y or n\n"; | |
| while(1){ | |
| cin >> key; | |
| if(tolower(key) == 'y'){ | |
| Delval(); | |
| cout << "data was deleted: "; | |
| return; | |
| } | |
| else if(tolower(key) == 'n'){ | |
| cout << "data was not deleted: "; | |
| return; | |
| } | |
| else{ | |
| cout << "invalid input: "; | |
| continue; | |
| } | |
| } | |
| return; | |
| } | |
| void Employee::Delval() | |
| { | |
| idnumber = 0; | |
| payrate = 0.0; | |
| numberofhours = 0; | |
| } | |
| int main() | |
| { | |
| int numofperson; | |
| cout << "enter a number of person to register: "; | |
| cin >> numofperson; | |
| Employee a[numofperson]; | |
| int counter = 1; | |
| int s = 0; | |
| int num; | |
| while(s < numofperson) | |
| { | |
| cout << "\nenter info for employee " << counter << endl; | |
| a[s].Setinfo(); | |
| cout << "the info has been set for employee " << counter << endl; | |
| a[s].Employeeinfo(); | |
| while(1) | |
| { | |
| cout << "\nfor employee " << counter << endl; | |
| cout << "\nmain menu: \n" | |
| << "-------- \n" | |
| << "1. add another employee \n" | |
| << "2. modify \n" | |
| << "3 delete this employee \n" | |
| << "4.display the info \n" | |
| << "5. exit \n" << endl; | |
| cin >> num; | |
| if(num == 1){ | |
| s++; | |
| counter++; | |
| cout << "\nenter info for employee " << counter << endl; | |
| a[s].Setinfo(); | |
| a[s].Employeeinfo(); | |
| continue; | |
| } | |
| else if(num == 2) | |
| { | |
| cout << "\nchange the info for employee " << counter << endl; | |
| a[s].Setinfo(); | |
| cout << "\nthe info has been change for employee " << counter << endl; | |
| a[s].Employeeinfo(); | |
| } | |
| else if(num == 3) | |
| { | |
| a[s].Deleteinfo(); | |
| continue; | |
| } | |
| else if(num == 4) | |
| { | |
| cout << "\ndisplaying the info for employee " << counter; | |
| a[s].Employeeinfo(); | |
| continue; | |
| } | |
| else if(num == 5) | |
| { | |
| cout << "\nexiting the program....." << endl; | |
| return 0; | |
| } | |
| else | |
| { | |
| cout << "invalid input: " | |
| << endl; | |
| continue; | |
| } | |
| } | |
| } | |
| cout << "\nmaxinum employee registered: exiting the program..." | |
| << endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment