Top Post

6/recent/ticker-posts

CS304 assignment 3 spring 2021 object oriented programming by vubwn.

 CS304 Assignment 3 spring 2021 Solution file download



Download PDF File


Download CPP File


Source Code is here:


// Provided by VUBWN
// This is just for get the idea, not for submit to teacher
// VUBWN.BLOGSPOT.COM
#include <iostream>
#include<string>
#include<windows.h>
using namespace std;
class Employee{
    public:
        string name;
        int age;
        void setname(string name){ this->name=name;}
        void setage(int age){ this->age=age;}
        string geter(){ return name;}
        double calculatesalary();
        void print();
};
class salariedEmployee:public Employee{
    public:
        double weeklysalary;
        double calculateSalary(){ return weeklysalary;}
        void print(){
            cout<<"***********Employee Details***********"<<endl;
            cout<<"Employee Name :"<<name<<endl;
            cout<<"Employee age :"<<age<<endl;
            cout<<"Employee Salary :"<<weeklysalary<<endl;
        }
};
class hourEmp:public Employee{
    public:
        double hours;
        double wage;
        double salary;
        double calculateSalary(){
            if(hours<=40){ salary=wage*hours; }
            elsesalary = (40*wage) +((hours-40)*wage*1.5); }
            return salary;
        }
        void print(){
            cout<<"***********Employee Details***********"<<endl;
            cout<<"Employee Name: "<<name<<endl;
            cout<<"Employee age: "<<age<<endl;
            cout<<"Employee Salary: "<<salary<<endl;   
        }
};
int main()
{   
    int iterate,x=0,y=0;
    system("Color 0A");
    cout<<"How many Emplyees data you want to enter?"<<endl;
    cin>>iterate;
    salariedEmployee sE[iterate];  
    hourEmp hE[iterate];
    char choice;
    for(int i=0;i<iterate;i++){
        cout<<"Enter choice:S for SalariedEmployee , H for hourlyEmp"<<endl;
        cin>>choice;
        if(choice=='S' || choice=='s'){
            cout<<"Enter name:"<<endl;
            cin>>sE[x].name;
            cin.ignore();
            cout<<"Enter age:"<<endl;
            cin>>sE[x].age;
            cout<<"Enter salary:"<<endl;
            cin>>sE[x].weeklysalary;
            x++;
        }
        else if(choice=='H' || choice=='h'){
            cout<<"Enter name:"<<endl;
            cin>>hE[y].name;
            cout<<"Enter age:"<<endl;
            cin>>hE[y].age;
            cout<<"Enter hours:"<<endl;
            cin>>hE[y].hours
            cout<<"Enter wage:"<<endl;
            cin>>hE[y].wage
            y++;
        }
    }
    for(int i=0;i<x;i++){
    sE[i].calculateSalary();
    sE[i].print();
    }
    for(int i=0;i<y;i++){
    hE[i].calculateSalary();
    hE[i].print();
    }
    return 0;
}

Post a Comment

0 Comments