Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   pllllllllllllz i need yr help or i'm ganna fail (http://www.go4expert.com/forums/pllllllllllllz-i-yr-help-im-ganna-fail-t24273/)

Tm07 27Dec2010 02:08

pllllllllllllz i need yr help or i'm ganna fail
 
Hi everybody

plz plz plllllllllllllllllllllllllz i need yr help i's my last Assignment and i need marks 2 paaas..my brin cloooooooose i dont know how 2 write the program :confused:
:embarasse can u help me plzz!!!


1) Write a complete program to open a sequential file with the name Account.text
And write the following statements in it “This is a Account file , and this file will have companies account details about its employees”
Write into the file with one function and open and read the file content with another function using a functions and classes

2) Write a complete program for the calculation of salary with the following perks being given by the company
· Housing 10% of basic salary
· Travel allowance 5% of basic salary
· Commission on sale 2% of basic salary
Calculate and print the salary after adding all the above benefits to the salary
Write a base class employee and derived class salary
Base class will have all the benefit variables like housing, travel, commission and the derived class will have functions to calculate them and set them each benefit will be calculated in a separate function in the derived class
Print the calculated salary in the base class,
Take the basic salary from the user

virxen 27Dec2010 04:34

Re: pllllllllllllz i need yr help or i'm ganna fail
 
sorry but if you cannot write this 2 programs or even try to then you deserve to fail.

if you want to pass start coding and we are here to help you.



p.s. check here

http://mathbits.com/MathBits/CompSci/Files/Create.htm

Tm07 31Dec2010 13:35

Re: pllllllllllllz i need yr help or i'm ganna fail
 
Quote:

Originally Posted by Tm07 (Post 76464)
Hi everybody

plz plz plllllllllllllllllllllllllz i need yr help i's my last Assignment and i need marks 2 paaas..my brin cloooooooose i dont know how 2 write the program :confused:
:embarasse can u help me plzz!!!


1) Write a complete program to open a sequential file with the name Account.text
And write the following statements in it “This is a Account file , and this file will have companies account details about its employees”
Write into the file with one function and open and read the file content with another function using a functions and classes

2) Write a complete program for the calculation of salary with the following perks being given by the company
· Housing 10% of basic salary
· Travel allowance 5% of basic salary
· Commission on sale 2% of basic salary
Calculate and print the salary after adding all the above benefits to the salary
Write a base class employee and derived class salary
Base class will have all the benefit variables like housing, travel, commission and the derived class will have functions to calculate them and set them each benefit will be calculated in a separate function in the derived class
Print the calculated salary in the base class,
Take the basic salary from the user

Thnxs 4 u bcs u let me 2 try 2 do the progrom in my oun..u know the bigest problem i dont know how 2 start 2 write a program << she is bad programer
u can say i'm stusy now 2 course cs101 & cs205 in this semester ..i had abaaaaaaad teacher in cs101 and she is not given us the steps How to write a program??
for now i have a very gooood teacher i wish God to protect her ..for now it's so difficult 4 me but i rely work hard..

i'm trying 2 do the second program..i know i'm not do eny thing i just write the steps but can eny budy explain for me what to do!!!!



Code:

#include<iostream>
#include<conio.h>
using namespace std;



class Salary
{
public:


                void add()
                {
                cout<<"Enter the basic salary \n "<<endl;


                }

               

       
protected:
       
};


class calculate : public Salary
                {
                public:
                        void function()
                        {

                                cout<<"THe basic salary is: "<<endl;



                        }

                private:
                               
                       
                };

void main()
{



getch();


}


Tm07 31Dec2010 13:41

Re: pllllllllllllz i need yr help or i'm ganna fail
 
Quote:

Originally Posted by Tm07 (Post 76464)
Hi everybody

plz plz plllllllllllllllllllllllllz i need yr help i's my last Assignment and i need marks 2 paaas..my brin cloooooooose i dont know how 2 write the program :confused:
:embarasse can u help me plzz!!!


1) Write a complete program to open a sequential file with the name Account.text
And write the following statements in it “This is a Account file , and this file will have companies account details about its employees”
Write into the file with one function and open and read the file content with another function using a functions and classes

2) Write a complete program for the calculation of salary with the following perks being given by the company
· Housing 10% of basic salary
· Travel allowance 5% of basic salary
· Commission on sale 2% of basic salary
Calculate and print the salary after adding all the above benefits to the salary
Write a base class employee and derived class salary
Base class will have all the benefit variables like housing, travel, commission and the derived class will have functions to calculate them and set them each benefit will be calculated in a separate function in the derived class
Print the calculated salary in the base class,
Take the basic salary from the user

Thnxs 4 u bcs u let me 2 try 2 do the progrom in my oun..u know the bigest problem i dont know how 2 start 2 write a program << she is bad programer
u can say i'm stusy now 2 course cs101 & cs205 in this semester ..i had abaaaaaaad teacher in cs101 and she is not given us the steps How to write a program??
for now i have a very gooood teacher i wish God to protect her ..for now it's so difficult 4 me but i rely work hard..

i'm trying 2 do the second program..i know i'm not do eny thing i just write the steps but can eny budy explain for me what to do!!!!



Code:

#include<iostream>
#include<conio.h>
using namespace std;



class Salary
{
public:


                void add()
                {
                cout<<"Enter the basic salary \n "<<endl;


                }

               

       
protected:
       
};


class calculate : public Salary
                {
                public:
                        void function()
                        {

                                cout<<"THe basic salary is: "<<endl;



                        }

                private:
                               
                       
                };

void main()
{



getch();


}


cpulocksmith 1Jan2011 13:32

Re: pllllllllllllz i need yr help or i'm ganna fail
 
when do you need to thave the programs by?

virxen 1Jan2011 14:57

Re: pllllllllllllz i need yr help or i'm ganna fail
 
Quote:

2) Write a complete program for the calculation of salary with the following perks being given by the company
· Housing 10% of basic salary
· Travel allowance 5% of basic salary
· Commission on sale 2% of basic salary
Calculate and print the salary after adding all the above benefits to the salary
Write a base class employee and derived class salary
Base class will have all the benefit variables like housing, travel, commission and the derived class will have functions to calculate them and set them each benefit will be calculated in a separate function in the derived class
Print the calculated salary in the base class,
Take the basic salary from the user
first of all write the code for this "Write a base class employee and derived class salary"

http://www.cplusplus.com/doc/tutorial/inheritance/

housing(0.1f), travel(0.05f), commission(0.02f) are float variables of the Employee class

Tm07 2Jan2011 23:20

Re: pllllllllllllz i need yr help or i'm ganna fail
 
ok thnxs 4 yr helpe ..i'm trying 2 do it right now
i have finsh from the first progrom can i know what's wrong!!!
Code:

#include<iostream>
#include<fstream>
#include<string>

using namespace std;



void print()
{
        r("This is a Account file , and this file will have companies account details about its employees");
}



class Reading
{
public:

        void Read()
        {
        ofstream r(" Account.text");
        }

private:
        int r;

};



void main()
{
Reading f;
f.Read();

}


Tm07 3Jan2011 01:59

Re: pllllllllllllz i need yr help or i'm ganna fail
 
OMG :crazy:
my brain will broken:cuss:..i'm ganna say yeeees i do it "but" it's wrong:D
i work hard and hard and hard plllllz help i shoud submit today!!!!
:nonod:<<no comment
this is my secound program:happy:

Code:

#include<iostream>
#include<conio.h>
using namespace std;



class employee
{
public:


                void add()
                {
                        //i dont under stand what i do hear!! i write just tha name?? if its yase can

                      //i write it in switch statements??!!

                }

               

       
protected:
       
};


class salary: public
                {
                public:
                        void function()
                        {
                               
                cout<<"Enter the basic salary \n "<<endl;
                cin>>i;

                mult=i*.10;
                cout<<mult;
                avg=mult/i;
                cout<<avg;
                cout<<"THe basic salary of Housing is:\n "<<avg<<endl;


               
                mult=i*.5;
                cout<<mult;
                avg=mult/i;
                cout<<avg;
                cout<<"THe basic salary of Travel allowance is:\n"<<avg<<endl;



               
                mult=i*.2;
                cout<<mult;
                avg=mult/i;
                cout<<avg;
                cout<<"THe basic salary of Commission on sale is:\n "<<avg<<endl;


                        }

                private:
                        int i;
                        double mult=1;
                        double avg=1;

                               
                       
                };

void main()
{
employee e;
e.add();
salary s;
s.function()

getch();

}


virxen 3Jan2011 05:50

Re: pllllllllllllz i need yr help or i'm ganna fail
 
Quote:

Originally Posted by Tm07 (Post 76761)
ok thnxs 4 yr helpe ..i'm trying 2 do it right now
i have finsh from the first progrom can i know what's wrong!!!

You could do it by yourself if you had followed my links.

one solution could be
Code:

/*
1) Write a complete program to open a sequential file with the name Account.text
And write the following statements in it “This is a Account file , and this file will have companies
account details about its employees”
Write into the file with one function and open and read the file content with another function using a
functions and classes

*/

#include<iostream>
#include<fstream>
#include<string>

using namespace std;

class FileHandling{
    public:
        void Read();
        void Write();
};
void FileHandling::Read(){
    ifstream fin;     
    fin.open("Account.text", ios::in);
    string item;
    getline(fin, item);
    fin>>item;
    cout<<"This is what i read from file:"<<endl<<item;
}
void FileHandling::Write(){
    ofstream fout;     
    fout.open("Account.text", ios::out);
    fout<<"This is a Account file , and this file will have companies account details about its employees"<<endl;
    fout.close();
}


int main(){
    FileHandling f;
    f.Write();
    f.Read();
    getchar();
}


P.S. i am giving you the code just because the deadline has passed, in order to know your mistakes for the next time

virxen 3Jan2011 06:34

Re: pllllllllllllz i need yr help or i'm ganna fail
 
and finally 2)

Code:

#include<iostream>
#include<conio.h>
using namespace std;



class employee{//Write a base class employee
//Base class will have all the benefit variables like housing, travel, commission
    public:
        float empSalary;
        float totalSalary;
        float housing;
        float travel;
        float commission;
        void printSalary();//Print the calculated salary in the base class,
        void getSalary();//Take the basic salary from the user
};
        void employee::printSalary(){
            cout<<endl<<"salary whith benefits is "<<totalSalary<<endl;
        }
        void employee::getSalary(){
            empSalary=0;
            while (empSalary<=0){
                cout<<endl<<"give employee salary: ";
                cin>>empSalary;
            }
        }     


class salary: public employee{//and derived class salary
    public:
        void setHousing(float);//and the derived class will have functions to calculate them and set them
        void setTravel(float);//and the derived class will have functions to calculate them and set them
        void setCommission(float);//and the derived class will have functions to calculate them and set them
        float calcHousing();//each benefit will be calculated in a separate function in the derived class
        float calcTravel();//each benefit will be calculated in a separate function in the derived class
        float calcCommission();//each benefit will be calculated in a separate function in the derived class
        void calcTotalSalary();
};
    void salary::setHousing(float value){
        housing=value;
    }
    void salary::setTravel(float value){
        travel=value;
    }
    void salary::setCommission(float value){
        commission=value;
    }
    float salary::calcHousing(){
        return empSalary*housing;
    }
    float salary::calcTravel(){
        return empSalary*travel;
    }
    float salary::calcCommission(){
        return empSalary*commission;
    }
    void salary::calcTotalSalary(){
        totalSalary=empSalary+calcHousing()+calcTravel()+calcCommission();
    }
int main(){
    salary s;
    s.getSalary();
    s.setHousing(0.1f);//Housing 10%=10/100=0.10 of basic salary
    s.setTravel(0.05f);//Travel allowance 5%=5/100=0.05 of basic salary
    s.setCommission(0.02f);//Commission on sale 2%=2/100=0.02 of basic salary
    s.calcTotalSalary();
    s.printSalary();
    getch();
}



All times are GMT +5.5. The time now is 07:54.