0% found this document useful (0 votes)
29 views

Homework

programming fundamentals

Uploaded by

Hibba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Homework

programming fundamentals

Uploaded by

Hibba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Question 1

#include “stdafx.h”

#include<iostream>

using namespace std;

class bank

string name;

int acc_no;

string type;

float balc;

int dep,wd;

char ch1, ch2;

public:

void input();

void withdraw();

void deposit();

void display();

};

void bank :: input()

cout << "Enter the name of employee="; cin >>name;

cout << "Mr./Mrs " << name <<"! Enter your account number= "; cin >>acc_no;

cout << "Enter your account type= "; cin >>type;

cout << "Now enter the balance in your account= "; cin>>balc;

void bank :: withdraw()

{
cout << "If you want to withdraw amount write Y! "; cin >> ch1;

if (ch1=='Y')

cout << "Enter the amount you want to Withdraw="; cin >>wd;

if(wd<balc)

balc = balc - wd;

else

cout <<"Not enough amount!";

void bank :: deposit()

cout << "If you want to deposit amount press Y! "; cin >>ch2;

if (ch2=='Y')

cout <<"Enter amount to deposit= "; cin >>dep;

balc = balc + dep;

void bank :: display()

cout << "Name of Employee= " << name <<endl;

cout << "Current Bank Balance= " <<balc <<endl;

cout << "Thank you!"

}
int main()

bank ep1;

ep1.input();

ep1.withdraw();

ep1.deposit();

ep1.display();

return 0;

Question 2
#include “stdafx.h”
#include <iostream>

using namespace std;

class employee

string name;

int age;

string desig;

float salary;

public:

void detail (employee*e,int a);

int max (employee*e,int a);

void output (employee*e, int a);

};

void employee :: detail (employee*e,int a)


{

for(int i=0; i<10; i++)

cout << "Enter your name here! "; cin >> e[i].name;

cout << "Your age: "; cin >> e[i].age;

cout << "Your Designation: "; cin >> e[i].desig;

cout << "Please enter your Salary: "; cin >> e[i].salary;

cout << "*************NEXT EMPLOYEE*****************" <<endl;

int employee :: max (employee*e,int a)

string y;

int z;

z=e[0].salary;

y=e[0].name;

for(int i=1;i<10;i++)

if(e[i].salary>z)

z=e[i].salary;

y=e[i].name;

return 0;

void employee :: output (employee*e,int a)

cout << "DETAILED LIST OF EMPLOYEE!" <<endl ;


for(int i=0; i<10; i++)

cout << "Detail of " <<e[i].name <<endl <<e[i].age <<"\t" <<e[i].desig <<"\t" <<e[i].salary <<endl;

int main()

int x;

cout <<"Enter the size: "; cin >>x;

employee*arr=new employee[x];

int res;

arr[0].detail(arr,x);

employee call;

arr[0].output(arr,x);

res=call.max(arr,x);

return 0;

Question 3
#include "stdafx.h"
#include<iostream>
#include<string>
using namespace std;

class student
{
private :
int id;
double marks;
string name;
public:
void setter();
void getter();
double getmarks();
};

//***********************************************
void student :: setter()
{
cout<<" id "<<endl;
cin>>id;
cout<<" name "<<endl;
cin>>name;
cout<<" marks "<<endl;
cin>>marks;
}

void student :: getter( )


{
cout<<" students information "<<endl;

cout<<id<<name<<marks<<endl;

double student:: getmarks()


{
return marks;
}

//*************************************************************

int _tmain(int argc, _TCHAR* argv[])


{
int size;
cout<<" total number of students: "<<endl;
cin>>size;
student *array = new student[size];
// array of students

for(int i=0; i<size; i++)


{
array[i].setter();

for(int i=0; i<size; i++){


array[0].getter();

cout<<"************************************************************
******"<<endl<<endl;
double var =0;
double total =0;

cout<<" enter total marks"<<endl;


cin>>total;
for(int i=0; i<size; i++){
var =var+array[0].getmarks();

var= var/total;

cout<<"avg marks are "<<var<<endl;

return 0;
}

You might also like