class
marks
{
private int mark1,mark2,total;
marks() {}
marks(int m1,int m2)
{
mark1 = m1;
mark2 = m2;
}
marks(marks m1)
{
mark1 = m1.mark1;
mark2 = m1.mark2;
}
void calc()
{
total = mark1 + mark2;
}
void putdetails()
{
System.out.println("Mark1
: " + mark1);
System.out.println("Mark2
: " + mark2);
System.out.println("Total
: " + total);
}
public static void main(String args[])
{
marks m1 = new marks(90,80);
marks m2 = new marks(m1);
marks m3 = new marks();
m1.calc();
m2.calc();
m1.putdetails();
m2.putdetails();
m3.putdetails();
}
}
No comments:
Post a Comment