Lab 6 B
Lab 6 B
Task-1
Write a recursive function in C++ that check if the given character array, which is passed in it is a
palindrome or not.
bool isPalindrome(char *start, char *end)// think cleverly about start and end pointers
Note: A character array is said to be palindrome if the reverse of the string is the same as the string.
Forexample ALPLA and KINGNIK are palindrome. TREE, FREE are not palindrome.
Task-2
Design an inventory class that can hold information and calculate data for items in a retail store’s
inventory. The class should have the following private member variables:
setTotalCost //Calculate the total inventory cost for the item(quantity times cost)
and //stores the result in totalCost
Task-3
Define a class FlightInfo in C++ with following description:
Private Members
A data member FlightNumber of type integer
A data member Destination of type char*
A data member Distance of type float
A data member Fuel of type float
A member function void calFuel() to calculate the value of Fuel as per the following criteria and set its corresponding
data member
Distance Fuel
<=1000 500
more than 1000 and <=2000 1100
more than 2000 2200
Public Members
A function void feedInfo() to allow user to enter values for Flight Number, Destination, Distance & call function void
calFuel() to calculate the quantity of Fuel
A function void showInfo() to allow user to view the content of all the data members
A function float getFuel() that returns the current fuel value.
Task 4:
Write a Circle class that has the following private member variables:
Radius – a double
Pi – a double initialized with the value 3.1 4159
The class should have the following public member functions:
Default Constructor- user define default constructor that sets radius to 0.0
Constructor- user define constructor that accepts the radius of the circle as an argument
SetRadius- a mutator for the radius variable
getRadius- an accessor for radius variable
getArea- return the area of the circle which is calculated as
area= pi * radius * radius
getdiameter- returns the diameter of the circle which is calculated as
diameter= radius * 2
getCircumference- returns the circumference of the circle
circumference=2 * pi * radius
National University of Computer & Emerging Sciences (NUCES), Islamabad
Write a C++ program that demonstrate the Circle class by asking the user for the circle’s radius, creating a Circle
object,then reporting the circle’s area , diameter,and circumference.
Submission Guidelines :
Do not zip your tasks, upload your tasks separately on GCR with naming convention:
TaskNumber_rollNumber.cpp