File Handling2

Guys, can you help me in this problem:
Write a cpp program that reads a text file named "employee.txt", which contains:

EMPO1, Juan, 1
EMPO2, Pedro, 2

The program requires to search for the code. Then the it prints the code and the salary on the file "record.txt"

Specs:

EMPO1 = code
Juan = name
1 = level

Salary:
level 1 = 200 pesos
level 2 = 250 pesos

Sample output:

Enter Code: EMPO1(entered by the user)

Name: Juan
Level: 1
Salary: 200 pesos.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <fstream>
using namespace std;
class level{
public:
    int lvl1;
    int lvl2;
private:
    void set_lvl1(int a){
        lvl1=200;
    }
    void set_lvl2(int b){
        lvl1=250;
    }

};
int main () {
  ifstream ER;
  string line, emp_code, name, lvl;
  ER.open("employee.txt");
  if (ER.is_open())
  {
       while ( ER.good() )
    {
      getline (ER,line);
      cout << line <<endl;
    }
    ER.close();
  }
  ios::beg;

  cout<<"Enter Code: ";
  getline(cin, emp_code);


  cout<<"Name: "<<name<<endl;
  cout<<"Level: "<<lvl<<endl;
  cout<<"Salary: "<<endl;



  return 0;
}

Last edited on
Topic archived. No new replies allowed.