#include<iostream.h>
#include<conio.h>
class product {
int pc,qty;
char nm[20];
float up,amt;
public:
product() {
cout<<"\n Enter Product Code : = ";
cin>>pc;
cout<<"Enter the Name : = ";
cin.get(); // to clear the buffer
cin.getline(nm,20);
cout<<"\n Enter unit price & qty : = ";
cin>>up>>qty;
}
void compute() {
amt = qty *up;
}
void putdata() {
cout<<"\n Product Code = "<<pc;
cout<<"\n Product Name = "<<nm;
cout<<"\n Total Amount = "<<amt;
}
~product() {
cout<<"\n Destroting object";
}
};
void main() {
clrscr();
product prod;
prod.compute();
prod.putdata();
getch();
}
OUTPUT:-
Enter Product Code : = 101
Enter the Name : = Pen
Enter unit price & qty : = 25 10
Product Code = 101
Product Name = Pen
Total Amount = 250
0 comments:
Post a Comment