Programming For Problem Solving: Experiment - 12
Programming For Problem Solving: Experiment - 12
EXPERIMENT – 12
Task 1: Create a class named “Shapes” with integer variable “Area”. Write
a member function “calArea” with two float parameters to calculate the
area of rectangle and overload the same function with having one float
parameter to calculate the area of square.
PROGRAM:
PROGRAM:
#include <iostream>
class Time {
private:
public:
HR = x;
MIN = y;
SEC = z;
void showTime()
{
cout << endl
void normalize()
HR = HR + MIN / 60;
Time operator+(Time t)
Time temp;
temp.HR = HR + t.HR;
temp.normalize();
return (temp);
};
int main()
t3 = t1 + t2;
t1.showTime();
t2.showTime();
t3.showTime();
return 0;
Task 3: write a program using class distance that creates an object and gets
value from user in feet and inches. It then adds these values with the values
of another object by overloading of + operator.
PROGRAM:
#include <iostream>
class Distance {
private:
public:
void readDistance(void)
void dispDistance(void)
{
return tempD;
};
int main()
D1.readDistance();
D2.readDistance();
D3 = D1 + D2;
return 0;
PROGRAM:
#include<iostream>
return x+y;
return x+y;
return x+y+z;
int main()