#include<iostream.h> #include<conio.h> /*************************************************************************///------------------------------ distance -----------------------------///*************************************************************************/class distance { private: int feet; float inches; public: void getdistance(); void showdistance(); }; /*************************************************************************///--------------------------- getdistance( ) --------------------------///*************************************************************************/void distance::getdistance() { cout<<"\t Enter feet = "; cin>>feet; cout<<"\t Enter inches = "; cin>>inches; } /*************************************************************************///--------------------------- showdistance( ) -------------------------///*************************************************************************/void distance::showdistance() { cout<<"\n\t Total distance is "<<feet<<"\' "<<inches<<'"'<<endl; } main() { clrscr(); distance obj[25]; char ans; int n=0; do { cout<<"\n Enter the distance number = "<<n+1<<endl; obj[n++].getdistance(); cout<<"\n Enter another (y/n)?"; cin>>ans; } while(ans!='n'); for(int i=0;i<n;i++) { cout<<"\n Distance number "<<i+1<<" is :"; obj[i].showdistance(); } getch(); return 0; }
No comments:
Post a Comment