S.O.S on a program

This is a discussion on S.O.S on a program within the C++ Programming forums, part of the General Programming Boards category; I been working on this program for some time, but i cannot find the way to execute it. i modify ...

  1. #1
    HELP-someone!
    Guest

    Question S.O.S on a program

    I been working on this program for some time, but i cannot find the way to execute it.
    i modify something and then another error appears.. could you givie me a hand to see if i can make it work..

    here's the code.

    --------------------------------------------------------------------------------
    //main driver

    #include <iostream.h>
    #include <fstream.h>
    #include <iomanip.h>
    //main driver

    #include <string.h>
    #include <conio.h>
    #include <process.h>

    #include "Employ2.h"
    #include "Boss1.h"
    #include "Commis1.h"
    #include "Piece1.h"
    #include "Hourly1.h"
    #include "workinfo.h"
    #include "workinfo.cpp"


    int menu();
    int n;

    int main()
    {

    int n=0;
    int choice;
    char answer;
    Worker w;

    do
    {
    choice = menu();

    //______________1st CHOICE__________________
    if (choice ==1)
    {
    do
    {
    w.SetEmpInfo(();
    w.TitleChoice();
    w.DisplayEmpInfo();
    w.DisplayTitleChoice();

    w.diskOut();

    cout<<endl;
    cout<<setw(17)<<" ""Do you want to enter another worker? (Y or N): ";
    cin >>answer;
    cout<<endl;
    }
    while (answer=='Y');
    }

    //_________________________________________
    // CHOICE 2

    if (choice==2)
    {
    do
    {
    int n= Worker::diskCount();
    for (int j=0; j<n; j++)
    {
    system("cls");
    w.diskIn(j);

    w.DisplayEmpInfo();
    w.DisplayTitleChoice();

    cout<<endl;
    cout<<setw(30)<<"See another worker? (Y or N): ";
    cin>>answer;
    }
    }
    while (answer=='Y');
    }

    //___________________________________________
    // CHOICE 3

    if (choice==3)
    {
    exit(0);
    }

    } while (choice !=3);
    cout<<endl;
    return menu();
    }

    //*********MENU ()

    int menu()
    {

    system("cls");
    system ("color 1c");

    int selection;



    cout<<"\n\n\n\n\n" <<setw(21)<<" "<<"MAIN MENU"
    <<"\n\n"
    <<setw(20)<<"_____________________________________ __________"<<"\n"
    <<"\n"<<setw(25)<<"1.- Add Information for a new worker\n"
    <<"\n"<<setw(25)<<"2.- Retrieve Information of a worker\n"
    <<"\n"<<setw(20)<<"3.- EXIT The Program\n\n"
    <<"\n"<<setw(20)<<"_______________________________ ________________"<<"\n\n"
    <<"\n"<<setw(20)<<"********* Enter your choice ****************\n"
    <<"\n"<<setw(20)<<" Choice: ";


    cin>>selection;

    return(selection);
    }

    --------------------------------------------------------------------------------

    // boss1.h
    // Boss class derived from Employee
    #ifndef BOSS1_H
    #define BOSS1_H
    #include "employ2.h"

    class Boss : public Employee {
    public:
    Boss( const char *, const char *, double = 0.0 );
    void setWeeklySalary( double );
    virtual double earnings() const;
    virtual void print() const;
    private:
    double weeklySalary;
    };

    #endif
    // boss1.h
    // Boss class derived from Employee
    #ifndef BOSS1_H
    #define BOSS1_H
    #include "employ2.h"

    class Boss : public Employee {
    public:
    Boss( const char *, const char *, double = 0.0 );
    void setWeeklySalary( double );
    virtual double earnings() const;
    virtual void print() const;
    private:
    double weeklySalary;
    };

    #endif
    --------------------------------------------------------------------------------
    // commis1.h
    // CommissionWorker class derived from Employee
    #ifndef COMMIS1_H
    #define COMMIS1_H
    #include "employ2.h"

    class CommissionWorker : public Employee
    {
    public:
    CommissionWorker( const char *, const char *,
    double = 0.0, double = 0.0,
    int = 0 );
    void setSalary( double );
    void setCommission( double );
    void setQuantity( int );
    virtual double earnings() const;
    virtual void print() const;
    private:
    double salary; // base salary per week
    double commission; // amount per item sold
    int quantity; // total items sold for week
    };

    #endif
    --------------------------------------------------------------------------------
    // employ2.h
    // Abstract base class Employee
    #ifndef EMPLOY2_H
    #define EMPLOY2_H

    class Employee {
    public:
    Employee( const char *, const char * );
    ~Employee(); // destructor reclaims memory
    const char *getFirstName() const;
    const char *getLastName() const;

    // Pure virtual function makes Employee abstract base class
    virtual double earnings() const = 0; // pure virtual
    virtual void print() const; // virtual
    private:
    char *firstName;
    char *lastName;
    };

    #endif
    --------------------------------------------------------------------------------
    // hourly1.h
    // Definition of class HourlyWorker
    #ifndef HOURLY1_H
    #define HOURLY1_H
    #include "employ2.h"

    class HourlyWorker : public Employee {
    public:
    HourlyWorker( const char *, const char *,
    double = 0.0, double = 0.0);
    void setWage( double );
    void setHours( double );
    virtual double earnings() const;
    virtual void print() const;
    private:
    double wage; // wage per hour
    double hours; // hours worked for week
    };

    #endif
    --------------------------------------------------------------------------------
    // piece1.h
    // PieceWorker class derived from Employee
    #ifndef PIECE1_H
    #define PIECE1_H
    #include "employ2.h"

    class PieceWorker : public Employee {
    public:
    PieceWorker( const char *, const char *,
    double = 0.0, int = 0);
    void setWage( double );
    void setQuantity( int );
    virtual double earnings() const;
    virtual void print() const;
    private:
    double wagePerPiece; // wage for each piece output
    int quantity; // output for week
    };

    --------------------------------------------------------------------------------
    #ifndef workinfo_h
    #define workinfo_h

    class workinfo
    {

    public:
    Worker(); // constructor

    void SetInfo();
    void DisplayInfo();
    void TitleChoice();
    void DisplayTitleChoice();
    void diskIn(int pn);
    void diskOut();
    void diskCount();

    private:

    char lname;
    char fname;
    int ssn;
    char address;
    int state;
    int zip;
    int phone;
    int dohire;
    double salary;
    double commision;
    int quantity;
    int hours;

    };
    #endif
    --------------------------------------------------------------------------------
    //workinfo.cpp
    // Member function definitions for class WorkInfo
    # include <iostream.h>
    # include <iomanip.h>
    # include <string.h>
    # include <conio.h>
    # include <process.h>
    # include <fstream.h>

    #include<iostream>
    using std::cout;
    using std::endl;
    using namespace std;
    #include<iomanip>
    using std::setw;

    # include "Employ2.h"
    # include "Boss1.h"
    # include "Commisl.h"
    # include "Piecel.h"
    # include "Hourly1.h"
    # include "Workinfo.h"

    int tc ;

    void Worker: : set EmpInfo()
    {
    char x [2]
    system ("cls");

    cout << "\n";
    cout<<"\t Enter the employee's last name: ";
    cin>> lname;

    cout << "\n";
    cout<<"\t Enter the employee's first name: ";
    cin>> fname;

    cout << "\n";
    cout<<"\t Enter the employee's social security number: ";
    cin>> ssn;

    cout << "\n";
    cout<<"\t Enter the employee's date of birth (mm/dd/yyyy): ";
    cin>> dobirth;

    cout << "\n";
    cout<<"\t Enter the employee's address: ";
    cin.getline(x, 2);
    cin.getline(address, 30);


    cout << "\n";
    cout<<"\t Enter the state: ";
    cin>> state;

    cout << "\n";
    cout<<"\t Enter zip code: ";
    cin>> zip;

    cout << "\n";
    cout<<"\t Enter the employee's phone number (***)-***-****: ";
    cin>> phone;

    cout << "\n";
    cout<<"\t Enter the employee's date hire (mm/dd/yyyy): ";
    cin>> dohire;

    }

    void Worker:isplayEmpInfo()
    {
    system("cls");
    cout << setw(5) << " " << " ************************************************** *****************
    **" << end1 ;
    cout << setw (31) << " " << "WORKER INFORMATION" << endl;
    cout << setw(5) << " " << " ************************************************** *****************
    **" << end1;

    cout << "\n" << setw(14) << " " << "Last Name: " << 1name
    <<setw(20) << " " << " First Name: " << fname << endl ;

    cout << "\n" << setw(14) << " " << " Social Security Number: " << ssn
    << endl;

    cout << "\n" << setw(14) << " " << " Date of Birth: " << do birth
    << endl;

    cout << "\n" << setw(14) << " " << "City: " << city << endl;

    cout << "\n" << setw(14) << " " << "State: " << state
    << setw(28) << " " << " Zip Code: " << zip<< endl;

    cout <<"\n" << setw(140 << " " << "Phone Number: " << phone << endl;

    cout << "\n" <<setw(14) << " " << " Date of Hire: " << dohire;

    cout << "\n\n" <<setw(5) << " " << "************************************************* *********************";

    {


    void Worker: :TitleChoice()
    {

    system ("cls");


    cout << "\n\n\n\n" << endl;
    cout << setw(20) << " " << " ___________________________________________" << endl;
    cout << "\n" ;
    cout << setw(30) << " " << " Select WORKER'S TITLE " << endl;
    cout << setw(20) << " " << " ___________________________________________" << endl;

    cout << "\n" << setw(31) << " " << "1) Boss" << endl;
    cout << "\n" << setw(31) << " " << "2) Commision Worker" << endl;
    cout << "\n" << setw(31) << " " << "3) Piece Worker" << endl;
    cout << "\n" << setw(31) << " " << "4) Hourly Worker" << endl;
    cout << setw(20) << " " << " ___________________________________________" << endl;
    cout << "\n\n" << setw(30) << " " << "Place choose one: " ;
    cin >> tc;

    system ("cls") ;
    swith (tc)
    {

    case 1:
    {
    cout << "\n\n" << endl;
    cout << "\tBoss information: " << endl;
    cout << "\t*****************" << endl;
    cout << \n\t\tEnter weekly salary: $ " ;
    cin >> weeklySal ;
    cout << end1; << endl;

    }
    break;
    case 2:
    {
    cout << "\n\n" << end1;
    cout << "\tCommision Worker information: " << endl;
    cout << "\t************************************" << endl;
    cout << "\n\t\tEnter salary: $ ";

    cin >>salary;
    cout << "\n\t\tEnter commision: $ " ;
    cin >> commision;
    cout << "\n\t\tEnter quantity: ";
    cin >> quantity;

    }
    break;

    case 3:
    {

    cout << "\n\n" << endl;
    cout << "\tPiece Worker information: " << endl;
    cout << "\t******************************" << endl;
    cout << "\n\t\tEnter wage per piece: $ " ;
    cin >> wage;
    cout << "\n\t\tEnter number of pieces: " ;
    cin >> quantity;
    }
    break;

    case 4:
    {

    cout << "\"\n\n" << endl;
    cout << "\tHourly Worker information: " << endl;
    cout << "\t******************************" << endl;
    cout << "\n\t\tEnter wage per piece: $ " ;
    cin >> wage;
    cout << "\n\t\tEnter number of hours: ";
    cin >> hours;
    }
    break;

    }
    }

    void Worker: : DisplayTitleChoice()
    {
    cout << endl;
    swicth (tc)
    {


    case 1:
    {

    Boss b ( fname, lname, weeklySal );
    b. print () ;
    cout << " earned $" << b. earnings () ;
    cout << endl;
    }
    break;

    case 2:
    {

    commisionWorker c ( fname, iname, salary, commision, quantity ) ;
    c. print () ;
    cout << " earned $" << c.earnings () ;
    cout << endl;
    }
    break;

    case 3:
    {

    piceWorker p ( fname, iname, wage, quantity ) ;
    p. print () ;
    cout << " earned $ " << p. earnings () ;
    cout << endl;
    }
    break;

    case 4:
    {

    HourlyWorker h ( fname, iname, wage, hours ) ;
    h. print () ;
    cout << " earned $ " << h.earnings () ;
    cout << endl ;
    }
    break;
    }
    }


    void Worker::diskIn(int pn)
    {
    ifstream infile;
    //infile.open("Worker.DAT", ios::binary);
    infile.open("D:\Documents and Settings\Owner\Desktop\FINAL\Worker.TXT");
    infile.seekg(pn*sizeof(Worker));
    infile.read((char*)this, sizeof(*this));
    }

    void Worker::diskOut()
    {
    ofstream outfile;

    // outfile.open ("WORKER.DAT, ios::app|ios::binary);
    outfile.open("D:\Documents and Settings\Owner\Desktop\FINAL\Worker.TXT");
    outfile.write((char*)this, sizeof(*this));

    }

    void Worker::diskCount()
    {
    ifstream infile;
    //infile.open("WORKER.DAT, ios::app|ios::binary);
    infile.open("D:\Documents and Settings\Owner\Desktop\FINAL\Worker.TXT");
    infile.seekg(0, ios::end);
    return (int) infile.tellg()/sizeof (Worker);
    }

    ------------------------------------------------------------------------------------
    //END OF PROGRAM

    // Thank you all for your help, I really appreciate it!

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Look here . Also, try asking some specific questions.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    S.0.S-
    Guest
    these type of errors i receive--


    D:\Documents and Settings\Owner\Desktop\Problems\workinfo.cpp(19) : fatal error C1083: Cannot open include file: 'Commisl.h': No such file or directory
    Error executing cl.exe.

  4. #4
    Registered User Azmeos's Avatar
    Join Date
    Jun 2003
    Posts
    65
    That's because you're including Commisl.h instead of Commis1.h

    see the difference - commisL versus commis1

  5. #5
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    In general...

    Start small... Just write enough code so that it compiles. Add a little code at a time, test-compiling and test-running as you proceed. This way you will know right away where the problems are.

    It takes a bit of practice to learn how to sequence your program development so that it's testable as you go along. Usually, the user interface, or input/output is started first (but maybe not finalized) so you can see what your program is doing.

    Programming is difficult, and every programmer test-compiles and test-runs during development. Beginners should test-compile every line or two! More experienced programmers might only test-compile every "page" or so, depending on how familiar they are with the particular functions they are using, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  2. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  3. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 01:27 PM
  4. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21