1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

pllllllllllllz i need yr help or i'm ganna fail

Discussion in 'C++' started by Tm07, Dec 26, 2010.

  1. Tm07

    Tm07 New Member

    Joined:
    Dec 26, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. virxen

    virxen New Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    0
    Tm07 likes this.
  3. Tm07

    Tm07 New Member

    Joined:
    Dec 26, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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();
    
    
    }
     
    Last edited by a moderator: Jan 2, 2011
  4. Tm07

    Tm07 New Member

    Joined:
    Dec 26, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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();
    
    
    }
     
    Last edited by a moderator: Jan 2, 2011
  5. cpulocksmith

    cpulocksmith New Member

    Joined:
    Jul 23, 2008
    Messages:
    289
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    student
    Location:
    canada
    when do you need to thave the programs by?
     
  6. virxen

    virxen New Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    0
    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
     
    Last edited: Jan 1, 2011
  7. Tm07

    Tm07 New Member

    Joined:
    Dec 26, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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();
    
    }
     
    Last edited by a moderator: Jan 3, 2011
  8. Tm07

    Tm07 New Member

    Joined:
    Dec 26, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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();
    
    }
     
    Last edited by a moderator: Jan 3, 2011
  9. virxen

    virxen New Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    0
    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
     
  10. virxen

    virxen New Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    0
    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();
    } 
    
    
    
    
    
    
     
  11. Tm07

    Tm07 New Member

    Joined:
    Dec 26, 2010
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Thaaaaaaaaaaaaaaaaaaanxs alot alot alot :crowd:
     

Share This Page