Wednesday, 27 April 2016

Array Of Objects With Classes

#include<iostream.h>
#include<conio.h>

class account
{
int accno;

public:
int balance;

void accept()
{
cout<<endl<<"Enter account no:";
cin>>accno;
cout<<"Enter balance:";
cin>>balance;

}

void display()
{
cout<<"-Balance after given interest of 10%:- "<<endl;
cout<<"Account no:"<<accno;
cout<<endl<<"Balance:"<<balance<<endl;
}
}a[10];

void main()
{
int i,balance;
clrscr();
for(i=0;i<10;i++)
{
a[i].accept();
if(a[i].balance>=5000)
{
a[i].balance=a[i].balance+(a[i].balance*0.1);
a[i].display();
}

}
getch();
}
/*Output:
Enter account no:45
Enter balance:5000
-Balance after given interest of 10%:-
Account no:45
Balance:5500

Enter account no:22
Enter balance:2000

Enter account no:48
Enter balance:200

Enter account no:33
Enter balance:100

Enter account no:66
Enter balance:777

Enter account no:88
Enter balance:100

Enter account no:19
Enter balance:9000
-Balance after given interest of 10%:-
Account no:19
Balance:9900

Enter account no:30
Enter balance:200

Enter account no:99
Enter balance:7777
-Balance after given interest of 10%:-
Account no:99
Balance:8554

Enter account no:77
Enter balance:1200

*/

No comments:

Post a Comment