Tuesday, 30 August 2011

Make the following statements considerate:

  1. When we travel on company expense, we will not receive approval for first class fare.

  2. We don’t refund if the returned item is soiled or non-salable.

  3. It is impossible to open an account for you today.

  4. We are delighted to announce 8% interest on saving accounts.

  5. We take pride to offer four different majors i.e. accounting, management, industrial management, and economics in The School of Management.

Answer

  1. When you travel on company expense, your approved fare is of tourist class.


  2. Your money will be refunded immediately if the returned item is clean and resalable.


  3. You will be able to open your account by tomorrow.


  4. You will be happy to receive 8% interest on your saving accounts.


  5. In the School of Management, you can major in accounting, management, industrial management, and economics.

    Make the following statements concise:

    1. Legislators are already in the process of reviewing the statutes.


    2. This policy has a tendency to isolate some communities.


    3. In my opinion, this wasteful policy ought to be revoked.


    4. There were many factors that influenced his decision to become a teacher.


    5. They played a football game that was exhaustive.

    Answer

    1. Legislators are already reviewing the statutes.


    2. This policy tends to isolate some communities.


    3. This wasteful policy ought to be revoked.


    4. Many factors influenced his decision to become a teacher.


    5. They played an exhaustive football game.

      Monday, 29 August 2011

      Write a short paragraph on the topic of your choice, using at least FIVE transitional markers.

      Answer

      Frequently used transitional markers are given below and students can write any paragraph of their choice making use of at least five of them. Any accurate transitional marker other than the mentioned ones will also be considered correct.

      Correct organization of a business message is important for both the audience and the communicator? Explain.

      Answer


      A good organization of a message will:

      1. Improve productivity. ( See the next page)

      By arranging the ideas in a logical and diplomatic way, you will increase the chances of satisfying the audience’s needs.

      2. Boost understanding.

      Audience will understand exactly what you mean

      3. Increase acceptance.

      Audience will comparatively believe the information/message conveyed.

      4. Save audience’ time.

      Well organized messages contain relevant information, so the audience does not waste time with superfluous information.

      Make the following statements considerate

      1. We are delighted to announce that we are opening a new store in Karachi.

      2. We don’t accept your claim of purchased goods but we have replacement for other goods.

      3. As our meeting venue is not finalized, we can call you at any other place.

      4. Our manager will be busy in the meeting on Monday, so he cannot meet you this time.

      5. The flights are cancelled, we are sorry that we will not be able to entertain you due to air smoke in Europe.

      Answer
      1. It will be happy news for you that you will find our new store in Karachi. 


      2. Your claim for purchased goods is accepted with replacement for other goods.


      3. You will be informed about the meeting place later.


      4. Your appointment with the manager is scheduled on Tuesday due to an important meeting on Monday


      5. As soon as the air space is clear in Europe, the new schedule of flights will be announced.


        You are required to write a program of class rectangle named CRectangle which should draw two rectangles by using iTop, iRight, iBot, and iLeft. Then program should calculate the area of both. Number of rectangles should be displayed to user by using static variable counter which would keep track of increment or decrement of rectangles. Dynamically Create another rectangle by using copy constructor and increment in counter should be displayed on screen. Decrement in static variable counter (after de-allocating memory which was dynamically allocated) should be displayed again on screen.

        Detailed Description:

        Sample Output

        Area of rectangle 1 is 6400

        Area of rectangle 2 is  5600

        The number of rectangles is 2          

        After using copy constructor, total number of rectangles is 3

        The number of rectangles is 2


        1. The class should have 4 members: iTop, iRight, iBot, and iLeft, all of type int.

        2. Area of both rectangles should be calculated by using iTop, iRight, iBot, and iLeft.

        3. It should have a default constructor and a copy constructor.

        4. It should have a destructor.

        5. It should contain all required getters and setters.

        6. It should contain a static member, iRefCount, which keeps track of the number of CRectangle objects. Increment it in the constructor, and decrement it in the destructor.

        Hint:

        CRectangle would implement rectangles by using left, right, top and bottom and calculate their areas to compare.

        Answer
        using namespace std;
        #include <iostream>
        #include <conio.h>
        class CRectangle {
            private:

         int   iLeft;                                                                    // Class members
         int   iTop;       
         int   iRight;     
         int   iBottom;    
         static int iRefCount;                                                        // Static variables   
        public:

         CRectangle::CRectangle (int l = 0, int t = 0, int r = 1, int b = 1);        // Constructors
         CRectangle::CRectangle (CRectangle& rect);
         CRectangle::~CRectangle ();


         int GetLeft() // Getters
            {
                return iLeft;
                    }                
         int GetTop() 
                    {
                return iTop;
                    }
         int GetRight() 
                    {
                return iRight;
                    }
         int GetBottom()
                    {
               return iBottom;
                    }

         void SetLeft(int iValue)                              // Setters
                    {
                iLeft = iValue;
                    }              
                   
            void SetTop(int iValue) 
                    {
                iTop = iValue;
                    }
               
         void SetRight(int iValue) 
                    {
               iRight = iValue;
                    }
                   
         void SetBottom(int iValue) 
                    {
               iBottom = iValue;
                    }
         int Area() 
                 {
                  return((iRight - iLeft) * (iBottom - iTop));
                  }

         static int GetRefCount()
                 {
                  return iRefCount;
                 }
        };
        int CRectangle::iRefCount = 0;                                  // Static variables
        CRectangle::CRectangle (int l ,int t , int r , int b)         // Default constructor
        {
         iLeft = l;
         iTop = t;
         iRight = r;
         iBottom = b;

         iRefCount++;
        }
        CRectangle::CRectangle (CRectangle& rect)                        // Copy constructor.
        {
         iLeft = rect.iLeft;
         iTop = rect.iTop;
         iRight = rect.iRight;
         iBottom = rect.iBottom;
         iRefCount++;
        }
        CRectangle::~CRectangle ()
        {
         iRefCount--;
        }
        int main()
        {
         CRectangle rect1(80, 120, 160, 200);
         CRectangle rect2(100, 140, 180, 210);
         int iArea = rect1.Area();                           // Calc area and output.
         cout << "Area of rectangle 1 is " << iArea << endl;
         iArea = rect2.Area();
         cout << "Area of rectangle 2 is " << iArea << endl;


         cout << "The number of rectangles is " << rect1.GetRefCount() << endl;    // Output total number of rectangles.


         CRectangle* pRectangle = new CRectangle();                               // Dynamically create a new instance of CRectangle.

         cout << "After using Copy constructor, total number of rectangles is " << rect1.GetRefCount() << endl;   // Output total number of rectangles.
         
         delete pRectangle;                                                       // Delete the rectangle object.


         cout << "The number of rectangles is " << rect1.GetRefCount() << endl;  // Output total number of rectangles.
         pRectangle = NULL;
            getch();
         return 0;
        }


        You are required to create a class in C++ named Price with the following Data members, Data members should be publicly declared.


        DetailedDescription:

        The Price class presents Price in Rupees and Paisa. For instance, Price (10, 80) means 10 rupees and 80 paisas. The Price class should have the following features as described in detailed descriptions:




        Constructors



        Class Price must have



        • Default constructor, which must set Rupees and Paisas to zero.




        • Parameterized constructor that receives two parameters of type int and initializes its private data: Rupees and Paisas with them. Note that if Paisas are 100 or greater than 100 then also convert it in Rupees.


        Member Functions

        • Create a function named Print()that displays the price of object in terms of rupees and paisas.


        Operator overloading

        • A member function that overloads the + Operator to add two objects of Price.




        There should be an overloaded + operators:



        • Add two objects and return Price object. Note that Paisas should not exceed 100.

        • Add first number into second objects and return Price object. Note that paisas should not exceed 100.






        Output of your program should be as follows:



        Price is 10 rupees and 60 paisas



        Price is 12 rupees and 80 paisas



        After Addition



        Price is 23 rupees and 40 paisas


        Answer

        #include <iostream.h>
        #include <stdlib.h>
        //definition for class Price
        class Price {         
             
              private:             
                      // private portion will contain no data member or function
                     
              public:
                 
                      int rupees, paisas;   //declaration for private data members of Price class
                     
              //prototypes for member functions and constructors of class
             
                      Price();                  // default constructor for class
                     
                      Price(int, int);           //parameterized constructor for class 
                      
                      Price operator +(Price &);         // + operator overloading function
                          
                      void Print();             // function prototype for printing price on screen
                     
        };              // class body ends here
        // definition for default constructor of class
        Price::Price()
        {
                      rupees = 0;
                      paisas = 0;
        }
        // definition for parameterized constructor of class
        Price::Price(int r, int p)
        {
                         if(p >= 100)   // condition to check if value of member paisa is great than 100 or not
                         {
                              paisas = p % 100;           // this will convert paisas into rupees if paisas are greater than 100
                              rupees = r + (p/100);       // if value of paisa is 100 or more then increment value of rupee by 1
                         }                
                         else
                         {
                              rupees = r;
                              paisas = p;
                         }                                   
        }
        // Function definition for overloading + operator 
        Price Price::operator + (Price &p)
        {
              Price temp;       // declaring a temporary variable for strong the result of addition
             
              temp.rupees = rupees + p.rupees;     // adding rupees value of both Price object in the rupees value of temporary object of Price       
             
              temp.paisas = paisas + p.paisas;     // adding paisas value of both Price objects in the paisas value of temporary object of Price
             
              if(temp.paisas >=100)                // checking if value of paisas after addition is greater than 100 or not
              {
                            
                             temp.rupees = temp.rupees + temp.paisas / 100;  // these statements below will convert paisas into rupees if value of paisas is greater than hundred
                             temp.paisas = temp.paisas % 100;                    
             
              }  
             
              cout<<"After Addition: "<<endl<<endl;    
             
              return temp;                              // returning the temporary object of type Price back to the calling function.
        }               
        // function definition to display the information about object on screen.
        void Price::Print()
        {
             cout<<"Price is "<<rupees <<" rupees and "<<paisas <<" paisas";    // statament to print price information on screen
             cout<<endl<<endl;   
        }
        // definition of main() function starts here
        main()
        {
              // declaring and initializing three objects of 'Price'
             
              Price P1(15, 80), P2(12, 50);        // parameterized constructor will be called here
             
              // default constructor Price object will be called here
              Price P3;       
             
              // displaying the information about the objects on the screen
              P1.Print();
              P2.Print();
             
              P3 = P1 + P2; // statement for calling overloading function for '+' operator     
             
              P3.Print();   // displaying information on the screen
              system("pause");    // function to halt the display screen
        }



        You are required to write a program which will calculate the salary of an employee according to his/her grade assigned by the employer. You must declare a class named CalSalary whose private data members will be employee ID, employee name and employee grade. Also write a constructor, setter and getter functions for all private data members and a function that will calculate the salary.


        Detailed Description:

        • Employee ID and grade should be of type integer. Employee name should be of type string.

        • Constructor should initialize employee ID and grade with value zero and employee name with value NULL.

        • For assigning or extracting values from private data members, you must use getter and setter functions.

        • Declare a public member function named calculate which will calculate the net salary of the employee according to his/her grade.

        • Formula for calculating actual salary is (Basic Salary) + 45% of basic salary.

        • If the grade of employee is 17, then the basic salary is 15,000.

        • If the grade is 18, then the basic salary is 20,000 and if grade is 19 then the basic salary is 25,000.




        Sample Output 1



        Please enter employee ID : 001

        Please enter employee name : Mohammad Ali

        Please enter employee grade : 17



        The net salary of Mohammad Ali is 21750







        Sample Output 2



        Please enter employee ID : 2

        Please enter employee name : Aslam Khan

        Please enter employee grade : 19



        The net salary of Aslam Khan is 36250



        Answer

        #include <iostream.h>   
        #include <cstring>
        #include <conio.h>
        //Class will calculate salary of an employee according to his grade
        class CalSalary{ 
            private:
                char name[30];          // character string for storing employee name
                int empID;              // employee's ID
                int grade;              // empoyee's grade 
           
            public:
                CalSalary();                // default constructor
               
                //getter methods for all private data members of class
                int getID();
                int getGrade();
                char* getName();
               
                //setter methods for all private data members of class
                void setName(char[]);
                void setID(int);
                void setGrade(int);
               
                //This function will calculate salary of employee on basis of his grade
                void calculate();
        };

          //Definition of default constructor which initializes employee name with Null and id and grade with zero
          CalSalary::CalSalary()
              {
                  strcpy(name, "");
                  empID = 0;
                  grade = 0;
                 
              }   

           int CalSalary::getID()  // Getter method for private member ID
              {
                  return empID;    // returning employee's ID
              
              }
           int CalSalary::getGrade()  // getter mehtod for private member Grade
              {
                  return grade;     // returning employee's grade
              
              }

            char* CalSalary::getName()  // getter mehtod for private member Name
              {
                  return name;     // returning employee's name
              
              }
           void CalSalary::setID(int id)   // setter method for private member ID
              {
                  empID = id;      // Setting id equal to the parameter given to setID()
              
              }

           void CalSalary::setGrade(int GRADE)    // Setter method for grade
              {
                  grade = GRADE;       // Setting grade equal to the parameter given to setGrade()
              
              }
           void CalSalary::setName(char NAME[])   // Setter method for private member name, taking a character array as argument
              {
                  strcpy (name, NAME);    // strcpy function is used to copy the character array in parameter to the private member name
              
              }
          
         
         
           void CalSalary::calculate()  // This function will calculate employee's salary
              {
                  int basic = 0;   // This variable represents basic salary of employee
                 
                  if(grade == 17)  // If employee's grade is 17 then setting basic salary = 15000
                    {
                      basic = 15000;
                    }       
                  if(grade == 18)  // If employee's grade is 18 then setting basic salary = 20000
                    {
                      basic = 20000;
                    }       
                  if(grade == 19)  // If employee's grade is 19 then setting basic salary = 25000
                    {
                      basic = 25000;
                    }       
              
             
              // Salary is calculated as basic salary + ( 45% of basic salary)
              cout << endl << "Net salary of " << getName() << " is Rs." << (basic + (basic * 45 / 100));
            }


        int main()
         {
           CalSalary obj1;  // creating an object of class CalSalary
           int Grade, id;
           char Name[30];       
            // Taking input from user for employee ID
            cout << "Please enter employee ID : ";
            cin >> id;
           
            cin.ignore();
            /* cin.ignor function is used here because when user enters value of ID and presses enter,
             the following statements like gets(Name) will consider the Enter character as input for character string Name
              and will by-pass these lines of code. cin.ignor() function will ignor the enter character so that
               user may enter his/her desired value of employee's name */

            cout << "Please enter employee name : ";  //Taking input from user for employee's Name
            gets(Name);
         
            cout << "Please enter employee grade : "; // Taking input from user for employee's Grade
            cin >> Grade;
         
               while(Grade<17 || Grade>19)   //Here we are putting a check on user's input for grade, which must be 17 - 19
                 {
                  cout << "Please enter employee grade again (between 17 - 19) : ";
                  cin >> Grade;
                 }
         
        // Using setter functions for setting the employee's name, Id and grade equal to user's input
           obj1.setName(Name); 
           obj1.setID(id);
           obj1.setGrade(Grade);
         
           obj1.calculate();  // calculating salary of employee and displaying on console
         
           getch();
         } 







        You are required to write a program which will take input from user in two integer arrays. The program should compare both arrays for checking if both arrays are totally identical (Exactly same). If not, then program should determine the matching indexes of both arrays. Matching indexes means that first element of array1 should be equal to first element of array2 and so on.


        Example of two identical (Exactly same) arrays:



        Array1        Array2

        1             1

        2             2

        3             3

        5             5

        7             7

        9             9

        11            11

        13            13

        15            15

        17            17





        Example of two arrays with some matching elements:



        Array1        Array2

        1             7

        2             9

        3             3

        5             4

        7             6

        9             8

        11            11

        13            15

        8             8

        17            17



        Here elements on index 3, 7, 9, and 10 of both arrays are same.







        Detailed Description:



         The program should take 10 integer inputs from user in arrray1 and array2.

        • After taking inputs in both arrays, you should pass both arrays to a function named match.

        • If both arrays are exactly same, the program should display a message “Both arrays are identical”.

        • If both arrays are not exactly same, then program should match the indexes which have same elements in both arrays and display the matching indexes.

        • If there is no element matching in both arrays, the program should display a message


          “There is no matching element in both arrays”.

        • Implementation regarding comparison of arrays and displaying message should be inside the function match.




        Sample Output for two exactly same arrays



        Please enter 10 integers for array1:

        Enter element 1 : 1

        Enter element 2 : 3

        Enter element 3 : 5

        Enter element 4 : 7

        Enter element 5 : 9

        Enter element 6 : 11

        Enter element 7 : 13

        Enter element 8 : 15

        Enter element 9 : 17

        Enter element 10 : 19



        Please enter 10 integers for array2:

        Enter element 1 : 1

        Enter element 2 : 3

        Enter element 3 : 5

        Enter element 4 : 7

        Enter element 5 : 9

        Enter element 6 : 11

        Enter element 7 : 13

        Enter element 8 : 15

        Enter element 9 : 17

        Enter element 10 : 19



        Both arrays are identical





        Sample Output for arrays with some matching indexes



        Please enter 10 integers for array1:

        Enter element 1 : 1

        Enter element 2 : 3

        Enter element 3 : 5

        Enter element 4 : 7

        Enter element 5 : 9

        Enter element 6 : 11

        Enter element 7 : 13

        Enter element 8 : 15

        Enter element 9 : 17

        Enter element 10 : 19



        Please enter 10 integers for array2:

        Enter element 1 : 2

        Enter element 2 : 4

        Enter element 3 : 5

        Enter element 4 : 6

        Enter element 5 : 9

        Enter element 6 : 12

        Enter element 7 : 14

        Enter element 8 : 16

        Enter element 9 : 17

        Enter element 10 : 20



        Both arrays have same elements on

        Index 3

        Index 5

        Index 9


        Answer


        #include <iostream.h>
        #include <conio.h>

        void match(int[], int[]);  // Declaration of match function for matching 2 arrays

        main()
        {
            int array1[10], array2[10];

        // Taking 10 integer inputs from user in array 1
          cout << "Please enter 10 integers for array1:" << endl;
          for(int i=0; i<10; i++)
           {
               cout << "Enter element " << i+1 <<" : ";
               cin >> array1[i];
           }
          
        // Taking 10 integer inputs from user in array 2          
          cout << endl<<"Please enter 10 integers for array2:" << endl;
          for(int i=0; i<10; i++)
           {
               cout << "Enter element " << i+1 <<" : ";
               cin >> array2[i];
           }

        //Passing both arrays to function match
        match(array1, array2);

        getch();
        } //End of main() function

        //Definition of function match taking two arrays as arguments
        void match(int Array1[], int Array2[])
         {

        int check = 0;  //This variable will be used to checked whether arrays are identical, with some same elements or have no same element
         
        /* In the following loop, we are comparing elements at same indexes of both arrays. If each
        element of both arrays is same, then variable "check" will be incremented 10 times.*/
          for(int i=0; i<10; i++)
               {
                 if(Array1[i] == Array2[i])
                  {
                    check++;
                  }
               }
              
           
        /* If variable check is incremented 10 times then it means that both arrays are exactly same*/
          if(check == 10)
             {
               cout << endl << "Both arrays are identical";
             }   
           

        /* If variable check is less than 10 and more than 0, it means that there are some elements which
        are same in both arrays at same indexes. So, here we will display matching indexes in both arrays*/    
          else if (check <10 && check > 0)
             {
               cout << endl<<"Both arrays have same elements on "<<endl;
                   for(int j=0; j<10; j++)
                     {
                       if(Array1[j] == Array2[j])
                           {
                             cout << "index " << j+1 << endl; 
                           }
                      }
                }
           
           
        /* If variable check=0, it means that there is no matching element in the both arrays*/
          else if(check == 0)
             {
               cout << endl << "There is no matching element in both arrays";
             }   

        }  

        You are required to write a program which should take input from user in the form of characters A or B. Based upon user’s input you should calculate no. of A grades. You should use while loop or do/while loop for taking input and if / else condition for making decisions.

        Detailed Description:
        The program should display like;

        Please Enter Grade (‘A’ OR ‘B’ )


        Then the program should take 10 inputs one by one,


        • After taking 10 inputs, you should display no. of A grades.

        • If A grades are less than or equal to 2, you should display a message “Your class is Poor!”.

        • If A grades are less than or equal to 7, you should display a message “Your class is Good!”.

        • If A grades are greater than or equal to 8, you should display a message “Your class is Brilliant!”.

        • The user should enter either A or B. If user has entered other than A or B, e.g. C,D,E etc. Your program should display a message like; 


             "Please Enter 'A' or 'B' grade only!"



        Sample Input and Output



        Please Enter Grade of student 1 :

        A

        Please Enter Grade of student 2 :

        A

        Please Enter Grade of student 3 :

        B

        Please Enter Grade of student 4 :

        A

        Please Enter Grade of student 5 :

        B

        Please Enter Grade of student 6 :

        B

        Please Enter Grade of student 7 :

        A

        Please Enter Grade of student 8 :

        B

        Please Enter Grade of student 9 :

        C

        Please Enter ‘A’ or ‘B’ grade only!

        Please Enter Grade of student 9 :

        A

        Please Enter Grade of student 10 :

        A

        Total No. of A Grades = 6


        Your Class is Good!



        Answer

        // header files for input and output
        #include <iostream.h> 
        #include <conio.h>

        main(){   // program will start execution from here
        // declaring required variables
        int  A_Grades = 0,    // will calculate no. of A grades
             B_Grades = 0,   // will calculate no. of grades, other than A
             count = 1;      // will be used as student count
           
             char input; // used to store input by the user

        do {
           
            cout << "Please Enter Grade of Student \t" << count << endl;  // taking user input for each student
            cin >> input;  

             if (input == 'A')    // checking if the input is A grade
              {    
                A_Grades++;          // adding 1 to A variable
                count++;        
                }       
           
             else if (input == 'B')   // checking if the input is B grade
               {   
                B_Grades++;   // adding 1 to other variable
                count++;        
                }
           
              else   // If input is not A or B
                 {
                 cout << "Please Enter 'A' or 'B' grade only!" << endl;
                   }   
                  
             }while (count <= 10);
           
              
            
               
        // displaying no. of A Grades in the class

        cout << "\nTotal No. of A Grades \t" << A_Grades << endl; 
            
             if (A_Grades <= 2)    {      // checking if A grades are equal to or more than 8
             cout << "\nYour Class is Poor\t" << endl;  // displaying message accordingly
             }    
             else if (A_Grades <=7 )    {      // checking if A grades are equal to or more than 8
             cout << "\nYour Class is Good\t" << endl;  // displaying message accordingly
             }    
             else if (A_Grades >= 8)    {      // checking if A grades are equal to or more than 8
             cout << "\nYour Class is Brilliant\t" << endl;  // displaying message accordingly
             }    
            
        getche(); // press any key to exit the program
        }