no 1
#include
class Box
{
double length, width, depth;
public:
void accept()
{
cout<<"length:";
cin>>length;
cout<<"width:";
cin>>width;
cout<<"depth:";
cin>>depth;
}
friend double calculate_volume(Box y);
};
double calculate_volume(Box y)
{return y.length*y.width*y.depth;}
void main()
{
Box obj;
obj.accept();
cout<<"Total Volume:"<
}
no 2.
#include
#include
class mark;
class Information
{
friend class info_student;
private:
char name[30],ic[10];
public:
void setmark(char*,char*);
};
void Information::setmark(char* a,char* b)
{ strcpy(name,a);
strcpy(ic,b);
}
class info_student
{
float mark1,mark2,total_point;
public:
void setmark(float,float);
void calculateMark();
void display(Information);
};
void info_student::setmark(float point1,float point2)
{
mark1=point1;
mark2=point2;
}
void info_student::calculateMark()
{
total_point=mark1 + mark2;
}
void info_student::display(Information a)
{
cout<<"name:"<
cout<<"IC :"<
cout<<"Mark of test 1:"<
cout<<"Mark of test 2:"<
cout<<"TOTAL MARK:"<
}
void main()
{
char name[30],ic[10];
float mark1,mark2;
info_student a;
Information b;
cout<<"Name:";
cin.getline(name,30);
cout<<"IC:";
cin.getline(ic,10);
cout<<"mark of test 1:";
cin>>mark1;
cout<<"mark of test 2:";
cin>>mark2;
cout<<'\n';
b.setmark(name,ic);
a.setmark(mark1,mark2);
a.calculateMark();
a.display(b);
}
isi tempat kosong yg korang rasa x lengkap..
iostream.h
iostream.h
string.h