.
Write a program to check a number is Even or Not using Constructor.
Find the Area of a Rectangle, circle and Triangle using Inheritance.
Write any program to call a member function which will be cause of a different function to be executed depending on the types of object that invokes the function.
Name: Md. Johorul Islam
ReplyDeleteID: 201720237
CSE-DIP-55 Batch
---------------------
problem 1 and 2 solved. can't understand problem 3.
https://drive.google.com/open?id=1VwddnM_7fOjpzh5uYdFOlhu9BSbmi12F
Name:Asib Bin Rhaman.
ReplyDeleteID:201730160
Dept:CSE(Diploma)
Batch:56th
Campus:Uttara.
----------------------
# Write a program to check a number is Even
or Not using Constructor.
#include
using namespace std;
class myClass
{
public:
myClass(int num)
{
if(num%2 == 0){
cout<
using namespace std;
class circle
{
public:
int radius;
circle(int x)
{
radius = x;
}
double area()
{
return radius*3.14;
}
};
int main()
{
int radius;
cout<<"Input circle radius = ";
cin>>radius;
circle obj(radius);
cout<<"Area of this circle = "<
using namespace std;
class triangle
{
public:
int base, height;
triangle(int x, int y)
{
base = x;
height = y;
}
double area()
{
return 0.5*base*height;;
}
};
int main()
{
int base, height;
cout<<"Input triangle base = ";
cin>>base;
cout<<"Input triangle height = ";
cin>>height;
triangle obj(base, height);
cout<<"Area of this triangle = "<
using
namespace std;
class ageCalc
{
public:
int birth, year = 2018;
ageCalc(int x)
{
birth = x;
age();
}
void age()
{
cout<<"You are about "<>birth;
ageCalc obj(birth);
}
output:
Which year do you born 1993
You are about 25 years old
Forhad Parvez
ReplyDeleteCSE-55th Batch
Roll: 201720297
https://pastebin.com/v5yuWpqi
Name: Md. Johorul Islam
ReplyDeleteID: 201720237
CSE-DIP-55 Batch
---------------------
problem 3 solution.
https://drive.google.com/open?id=1tu71NQK8ERg8pnoecj1y1fVAClQZ_5U5
Fazle rabbi khan taron
ReplyDelete201720263
55th
#include
using namespace std;
class Shape {
protected:
int width, height;
public:
Shape( int a = 0, int b = 0){
width = a;
height = b;
}
int area() {
cout << "Parent class area :" <<endl;
return 0;
}
};
class Rectangle: public Shape {
public:
Rectangle( int a = 0, int b = 0):Shape(a, b) { }
int area () {
cout << "Rectangle class area :" <<endl;
return (width * height);
}
};
class Triangle: public Shape {
public:
Triangle( int a = 0, int b = 0):Shape(a, b) { }
int area () {
cout << "Triangle class area :" <<endl;
return (width * height / 2);
}
};
class Rectangle
{
int l,b;
Rectangle(int x,int y)
{
l=x;
b=y;
}
int getRectangle()
{
return l*b;
}
}
class Triangle extends Rectangle
{
float a;
Triangle(int v,int u)
{
super(u,v);
}
float getTriangle()
{
a=(float)l/2*l*b;
return (a);
}
}
class RectangleTriangle
{
public static void main(String args[])
{
Triangle m=new Triangle(500,80);
System.out.println("Area of Rectangle is : " +m.getRectangle());
System.out.println("Area of Triangle is : "+m.getTriangle());
}
}
import java.util.Scanner;
class OddOrEven
{
public static void main(String args[])
{
int x;
System.out.println("Enter an integer to check if it is odd or even ");
Scanner in = new Scanner(System.in);
x = in.nextInt();
if ( x % 2 == 0 )
System.out.println("You entered an even number.");
else
System.out.println("You entered an odd number.");
}
}
Name: Jibon Chandra Roy
ReplyDeleteID: 201730589
CSE-DIP-56 Batch
https://www.dropbox.com/s/1ok1rgn0kr6mnll/Assignment.pdf?dl=0
Name: Md.Toufiqur Rahman
ReplyDeleteID: 201730027
CSE-DIP-56 Batch
--------------------
https://drive.google.com/file/d/1f07RNZW5xDPG37W8GxCeHKjZAlXDUeP2/view
Minhazul Abid Sakin
ReplyDeleteroll: 201720265
batch: 55th
https://docs.google.com/document/d/1Q36Zy9q0tH5LKGeh4sNVNkra51fRg8IZUZ5gtGg0B-s/edit?usp=sharing
Name: Sayeka Jannat
ReplyDeleteID: 201720097
CSE-DIP-55 Batch
1. Write a program to check a number is Even or Not using Constructor.
#include
using namespace std;
class exam
{
int n;
public:
exam()
{
cout<<"Enter a number: \n";
cin>>n;
if(n%2==0)
cout<<" This is a EVEN number ";
else
cout<<"This is a Not a even number";
}
};
int main()
{
exam();
return 0;
}
2. Find the Area of a Rectangle, circle and Triangle using Inheritance.
#include
using namespace std;
class exam{
public:
int a=4,b=5,c=7;
int ractangle(){
return a*b;
}
};
class date: public exam
{
public:
int triangle()
{
return (a*b/2);}
float circle(){
return 3.14*c*c;}
};
int main()
{
date obj;
obj.ractangle();
obj.triangle();
obj.circle();
cout<<obj.ractangle()<<endl;
cout<<obj.triangle()<<endl;
cout<<obj.circle();
return 0;
}