Você está na página 1de 2

National University of Computer and Emerging Sciences

Islamabad.
Programming for Engineers-II
Sections-A, B, C, D
Assignment # 2
Marks=100
Semester: Spring 2011
Due Date: 26th Feb, 2011
Instructors: Qurat-ul-Ain/Nisar Ahmad
In this assignment you have to write a complete program in VC++ 6.0.

Question-1: (60 pts)


Implement a class Employee. An employee has a name (a char *), age (int), and a basic-salary (a
double), commission(double), sales value(double), tax(double).
 Write a default constructor and another constructor with 5 values parameters (name, age,
basic_salary, commission and sales_value)
 Set functions for setting the values of name, age, basic salary, commission and sales
value.
 Get functions for getting (retrieving) the values of name, age, basic salary, commission
and sales value.
 Utility Functions
1. For calculating Total salary
 Total_Salary= basic_salary+commission*sales_value
2. For Calculating Tax
 Tax = Total_Salary*Tax_Rate;
 Tax_Rate = 2% if Total_Salary < 10,000
 Otherwise Tax_rate=5%
 Access Functions
1. for getting the value of Tax
2. and Total Salary
 Write a small program to test ALL constructors and public functions of your class

Question-2: (40 pts)


 Implement a class Shape. This class will have following two private data members:
1. Type (int - 0 representing Square, 1 representing a Cube)
2. Side (float – positive value for the length of one side in meters)
 Write two constructors
1. Default constructor (no arguments) which creates a square of side length 1m.
2. Constructor that takes type and side as arguments and initializes them using
Initializer List.
 Write Member Access Functions (get/set) for both private members.
 Write the following public functions:
1. float Area( )
 returns area of the shape (Note: area of cube = 6*side*side)
2. float Volume( )
 if shape is cube then it returns volume otherwise returns 0.
3. void Properties( )
 Displays the shape properties based on its type. E.g. if the shape has the
side length of 2 and it is a square then this function should print “This is a
square having an area of 4 meter-sq.”
 If the shape is a Cube then it will print “This is a Cube having a total
surface area of 24 meter-sq and a volume of 8 meter-cube.”
 Write a small program to test ALL constructors and public functions of your class

Bonus Points (10):


Separate the code into 3 files (interface, implementation and test program in main) for each
question. Create a separate folder for files of each question. Submit ONE zip file which contains
these two folders.

Guidelines:

 Write comments regarding each member attribute and method.


 Submit your assignment at slate web portal
o Go to “Messages”
o Attach assignment
o Select ROLE of INSTRUCTOR
o Send

Submission by Email (if Slate is not working)

Subject: Assignment02_prog2

Submit ONE ZIP file named according to your roll-no (e.g. 10-0xxx.ZIP). This should contain
separate source files (or folders) for question 1 and 2.

Section A & B will send their assignments to:


attique.dawood@nu.edu.pk

Section C & D will send their assignments to:


hina.ashraf@nu.edu.pk

Você também pode gostar