Professional Documents
Culture Documents
#include<iostream>
class BANK_539
private:
int accno_539;
float balance_539;
string acctype_539;
public:
void assignValues_539()
cin>>accno_539;
cin>>acctype_539;
cin>>balance_539;
void withdraw_539()
{
float take_539;
cin>>take_539;
balance_539=balance_539-take_539;
void deposit_539(){
float give_539;
cin>>give_539;
balance_539=balance_539+give_539;
void DISPLAY_539()
is :"<<balance_539; }
};
int main()
BANK_539 B;
B.assignValues_539();
B.withdraw_539();
B.deposit_539();
B.DISPLAY_539();
return 0;
OUTPUT:
Constructors and Destructors Que 8-A book shop maintains the inventory of
books that are being sold at the workshop. The list includes details such as author, title,
price, publisher and stock position. Whenever a customer wants a book, the sales person
inputs the title and author and the system searches the list and displays whether it is
available or not. If it is not, an appropriate message is displayed. If it is, then the system
displays the book details and requests for the number of copies required. If the
requested copies are available, the total cost of the requested copies is displayed
otherwise the message “Required copies not in stock” is displayed. WAP using a class
called Books with suitable member functions and constructors.
#include<iostream>
#include<string.h>
class books_539
private:
float price_539;
int stock_539;
public:
void getdata_539();
void display_539();
void buy_539();
books_539();
};
books_539::books_539()
title_539=new char[50];
author_539=new char[50];
publisher_539=new char[10];
price_539=0;
stock_539=0;
void books_539::getdata_539()
cin.ignore();
cin.getline(author_539,50);
cin.getline(title_539,50);
cin.getline(publisher_539,10);
cin>>stock_539;
void books_539::display_539()
cout<<"\nPrice: "<<price_539;
return 1;
else
return 0;
void books_539::buy_539()
int no_of_copies_539;
cout<<"\nEnter no. of copies required:";
cin>>no_of_copies_539;
if(no_of_copies_539<= stock_539)
else
int main()
int val=0;
int ch;
int n;
char a;
cin>>n;
cout<<"\n";
books_539 b[n];
char title1[50],author1[50];
for(int i=0;i<n;i++)
b[i].getdata_539();
cin.ignore();
do
{
cout<<"**MENU*\n";
cin>>ch;
switch(ch)
case 1:
for(int i=0;i<n;i++)
cout<<"---------------------------------\n";
b[i].display_539();
}
break;
case 2:cin.ignore();
cin.getline(author1,50);
cin.getline(title1,50);
for(int i=0;i<n;i++)
val=b[i].search_539(title1,author1);
if(val==1)
cout<<"\nBook is found";
if(val==0)
return 0;
break;
case 3:cin.ignore();
cin.getline(title1,50);
for(int i=0;i<n;i++)
val=b[i].search_539(title1,author1);
if(val==1)
cout<<"\nBook is found";
b[i].buy_539();
}
}
if(val==0)
return 0;
break;
cin>>a;
}while(a=='y' || a=='Y');
return 0;
}
Miscellanious Que 15-A ball is thrown up in the air. Its height above the
ground is given by the formula h = 3 + 10t – t2 where t is the time in seconds
after it is thrown. For example, at Time t = 0, h = 3 + 0 - 0 = 3 Time t = 2, h =
3
+ 20 – 4 = 19 When the ball hits the ground, h becomes negative. WAP to
print out the height, h, once every second, starting a t = 0, and continuing
until h becomes negative (meaning the ball has hit the ground). (Do not print
the negative value.)
->#include <bits/stdc++.h>
#include <math.h>
while (Height_539
>=0) {
Time_539++;
cout << "At ->" << Time_539 << " second the Height is ->" << Height_539 <<
" units" << endl;
Height_539 = 3 + (10 * Time_539) - (Time_539 * Time_539);
int main()
is 0 Height_539(StartTime_539, InitialHeight_539);
return 0;
Output: