Monday 19 October 2015

Q. Write in c++ a class called 'Employee'. Write class called 'Part time Employee' and Fulltime employee. write a method called 'monthly_pay' to compute cost of pay, part time employee is paid as per number of working hours and full time employee is paid as per no of working days. create different types of employees using array and compute the pay for all...?

----for the below code obtaining errors suggest me please----

#include<iostream>
#include<cstring>
using namespace std;

class Employee
{
   protected:
               char emp_name[50];
               int emp_type;
              double salary;
public:
      Employee()
     {
                emp_name[0]='\0';
                emp_type=0;
      }
                Employee(const char* n,int t)
               {
                        strcpy(emp_name,n);
                        emp_type=type;
                }
                     virtual double getSalary()
                 {
                      return 0;
                  }
                     virtual void monthly_pay()
                  {
                        cout<<"Employee in leave\n";
                   }
     };
       class Fulltime_employee: public Employee
    {
                int days;
        public:
              Fulltime_employee(int d)
             {
              days=d;
       }
               void monthly_pay()
             {
                 salary=days*700;
               }
                      double getSalary()
                        {
                                 return salary;
                         }
             };
                class Parttime_employee:public Employee
                 {
                       int hours;
              public:
                       Parttime_employee(int h)
                {
                        hours=h;
                 }
               void monthly_pay()
                {
                        salary=hours*150;
                 }
                double getSalary()
                 {
                         return salary;
                  }
            };
    main()
    {
             Employee *a[5];
             for(int i=0;i<5;i++)
                {
                      int type,opt;
                      char n[10];
                             cout<<"Enter employee name:";
                             cin>>n;
                             cout<<"Enter 1.Fulltime,2.Parttime:";
                             cin>>opt;
               Employee(n,type);
               switch(opt)
                {
                  case 1: int d;
                          cout<<"Enter days:";
                           cin>>d;
                           a[i]=new Fulltime_employee(d);
                           break;
                  case 2: int h;
                           cout<<"Enter hours:";
                           cin>>h;
                           a[i]=new Parttime_employee(h);
                           break;
                          }
                   }
                  for(int i=0;i<5;i++)
                      {
                         a[i]->monthly_pay();
                         cout<<a[i]->getSalary()<<endl;
                        }
                    for(int i=0;i<5;i++)
                         {
                             delete a[i];
                          }
                }

My Programming experience....!!!iiiiii!!iiiiii

This is generally for non IT people who wish to pursue their career in IT field. I would like to share my experience, as I also belong to non-IT background. I completed my  BE degree in electrical and electronics stream in 2015.Though I had interest in this branch, I always wished to join some core electrical company, I was also good in studies and also got good percentage in my engineering. But the same time I also had good interest in programming. In my first year I had one subject related to basic c programming and it is there in every university syllabus, I guess. I had not tasted the essence of programming till then , so I was not sure about my programming skills. Again in my 3RD year I had one more subject related to bit programming i.e. 8051 Microcontroller and that involves assembly language program and embedded C. Trust me, I really enjoyed that subject. We have to interface microcontroller with some hardware like motor, relays, LED etc. and I found that the embedded C seemed to be easy and simple for me. From there my real passion for programming began. I started reading book related to C again and I started working on other microcontroller also i.e. NXP 1768, PIC microcontroller, I used to download pdf and videos related to them.  And few other classmates of mine, kept suggesting the core company, they use to say why people shift to IT field from non-IT field.  At that time, I had no clear idea which field to go.
In final year we had to do project, I was clear from my side that I have to do project related to microcontroller but my other friend opposed by saying that they had to do programming in that and that also in PIC microcontroller which they had never studied. But I had made my mind and I influenced them to agree upon the project. Finally as a result of our hard-work the project was ready and it felt like I finally achieved something.
The purpose of sharing is that, I want to say that for becoming programmer you don’t need to be from CS or IT background. According to me how creative you are and how differently you think is all that matters. Your logical approach should be good and clear. You should have the determination to take up the challenges and a little hard-work that’s all you need, to be a good programmer. If you have studied any programming language and you have interest in that then go for it. Don’t think that I don’t know JAVA, C++ and other things, always remember only syntax differs in every language but the logical approach remain the same.
Later, I joined one of the reputed IT MNC company, where I am learning other language like C++, Python etc. and I am really enjoying it.  So I want to tell every other student who is in college or wishing to join IT field, branch doesn’t matter and it will not decide your career path. It is you who decides your career, your life and go for it!!


Need explanation.....?

I want to know details regarding polymorphism in sense of method overriding.
 

Tuesday 1 September 2015

Description of our blog

This is the blog which we created for the people who have passion on programming.Anyone can visit this group and post their comments,opinions,questions regarding programming.We will get back to you soon with the solution if we have.Please feel free to post.
"Let all be a part of this blog..."