I need some help.

I need help with creating a program that allows the user to enter a payroll code. The program should search for the payroll code in the file and then display the appropriate salary. If the payroll code is not in the file, the program should display an appropriate message. Use a sentinel value to end the program. Test the program using the following payroll codes: 10, 24, 55, 32, and 6. Stop the program by entering your sentinel value.

I know this my homework. I haven been working on it for hours. I am taking an online class so I have little help from the Professor. I have sent a message to my online classmates for help I still haven't got a response. I have some code that I have written. I don't know if I need to make a function. Any help would be nice.

Here is what I got so far. (I know its not close to correct) Just showing that I need hints and help.
// ch14.24.621.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <istream>
#include <string>
#include <fstream>
using namespace std;



int main()
{
string paycode ="";
string salary = "" ;
ifstream inFile;
inFile.open("Intermediate24hw.txt");
if(inFile.is_open()==true)
{
cout <<"Enter the PayCode:";
getline(inFile,paycode, '#');
inFile >> salary;
inFile.ignore();



cout <<"Salary:"<< salary << endl << endl ;
}
else
cout <<"Error";
system("pause");
return 0;
}



File data:

1#27200
2#15000
3#23000
4#12000
5#25500
6#18400
7#19500
8#32000
9#29000
10#16500
20#65000
21#65500
22#70200
23#71000
24#71100
25#72000
30#83000
31#84000
32#90000


Last edited on
Topic archived. No new replies allowed.