Professional Documents
Culture Documents
Huzaifa Muqeet-051
Huzaifa Muqeet-051
Course title:
Course code:
SE-104
Submitted to:
Mr.Naveed Abbas
Submitted by:
Huzaifa muqeet
Roll no:
22014198-051
Section:
BS-SE-22 A
Department:
Software engineering
OOP LAB TASK
Q#1.
Writer class player that contain attributes for the player attibutes average and
team. Write three function to input change and display these attributes also write
a constructor that ask input to initialized all the attributes.
Ans.
#include <iostream>
using namespace std;
class player{
private:
char team[120];
double average;
public:
player(){
cout<<"Enter player team: ";
cin.getline(team,120);
cout<<"Enter player's average: ";
cin>>average;
}
void display();
int changer();
};
Output:
Enter player team: colombia
Enter player's average: 14
Player's Team is colombia
Player's average is 14
Define a class for a bank account that includes the following data members
name of the depositor account number type of account balance amount in the
account. Ji class also contain the following member function Constructed to assign
initial values. Devotional functions to deposit some amount it should accept the
amount as perameters. The functions to withdraw and amount after checking the
balance it should accept the amount as parameters. Display function to display
name and balance.
Ans.
#include <iostream>
using namespace std;
class BankAccount {
private:
string name;
int accountNumber;
string accountType;
float balance;
public:
BankAccount(string n, int aN, string aT, float b) {
name = n;
accountNumber = aN;
accountType= aT;
balance = b;
}
void display() {
cout << "Name: " << name << endl;
cout << "Account Number: " << accountNumber << endl;
cout << "Account Type: " << accountType << endl;
cout << "Balance: " << balance << endl<<endl;
}
};
int main() {
BankAccount account1("Hanzala", 22014198060, "current", 10099.0);
account1.display();
account1.deposit(599.0);
account1.display();
account1.withdraw(999.0);
account1.display();
return 0;
}
Output:
Name: Huzaifa
Account Number: 539361580
Account Type: current
Balance: 10099
Name: Huzaifa
Account Number: 539361580
Account Type: current
Balance: 10698
Name: Huzaifa
Account Number: 539361580
Account Type: current
Balance: 9699
<========================>