Sr No
|
Title
|
Remark
|
1
|
Implement a class Complex which represents the Complex Number data
type. Implement the following operations :
1. A
constructor (including a default constructor which creates the complex number
0+0i).
2. Overloaded
operator+ to add two complex numbers.
3. Overloaded
operator+ to multiply two complex numbers.
4. Overloaded
<< and >> to print and read Complex Numbers to do this, you will
need to decide what you want your input and output format to look like.
|
|
2
|
Implement a class Quadratic that represents two degree polynomials
i.e., polynomials of type ax2+bx+c. Your class will require three data
members corresponding to a,b and c. Implement the following operations:
1. A
constructor (including a default constructor which creates the 0 polynomial).
2. Overloaded
operator+ to add two polynomials of degree 2.
3. Overloaded
<< and >> to print and read polynomials. To do this, you will
need to decide what you want your input and output format to look like.
4. A
function eval that computes the value of a polynomial for a given value of x.
5. A
function that computes the two solutions of the equation ax2+bx+c=0.
|
|
3
|
Write a program to create four-function calculator using C++. The
Program should ask the user to enter a number, an operator, and another
number.(use floating point.) It should then carry out the specified
arithmetical operation: adding, subtracting, multiplying, or dividing the two
numbers. Use a switch statement to select the operation. Finally, display the
result. When it finishes the calculation, the program should ask whether the
user wants to do another calculation. The response can be _y’ or _n’. some
sample interaction with the program might look like this:
Enter first number, operator, second number: 10/3
Answer=3.333333
Do another(y/n)?y
Enter first number, operator, second number: 12+100
Answer=112
Do another(y/n)?y
|
|
4
|
Create student database with appropriate data members that should use
the following features of object oriented programming in C++. Class, object,
array of objects, new, delete, default constructor to initialize student
class fields, parameterized constructor to set the values into the objects,
access specifiers, this pointer.
|
|
5
|
Implement C++ program to write a class template to represent a
generic vector. include following member functions :
1. To
create the vector
2. To
modify the value of a given element
3. To
multiply by a scalar value
4. To
display the vector in the form (10, 20, 30,…)
|
|
6
|
Imagine a publishing company that markets both book and audiocassette
versions of its works. Create a class publications that stores the title (a
string) and price (type float) of a
publication. From this class derive two classes: book, which adds a page
count (type int), and tape, which adds a playing time in minutes (type
float). Each of this three classes should have a getdata() function to get
its data from the user at the keyboard, and a putdata() function to display
its data.
Write a main() program to test the book and tape classes by creating
instances of them, asking the user to fill in data with getdata(), and then
displaying the data which putdata().
|
|
7
|
Write a function in C++ to
count and display the number of lines not starting with alphabet ‘A’ present
in a text file “STORY.TXT”
Example:
If the file “STORY.TXT” contains the following lines,
The roses are red.
The girl is playing there.
There is a playground.
An aero plane is in the sky.
Numbers are not allowed in the password.
The function should display the output as 3.
|
|
8
|
A book shop maintains the inventory of books that are being sold at
the shop. The list includes details such as another , title, price, publisher
and stock position. Whenever a customer wants a book, the sales person inputs
the title and another and the system searches the list and displays whether
it is available or not. If it is not, 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 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. Design a system using a class called books
with suitable member functions and constructors. Use new operator in
constructors to allocate memory space required. Implemenent C++ program for
the system.
|
|
9
|
Create employee bio-data using following classes i) Personal record ii) Professional record iii)Academic record . Assume appropriate data members and member function to accept
required data and bio-data. Create bio-data using multiple inheritance using
C++ .
|
|
10
|
Create user defined exception to check the following condition and throw
the exception if the criterion does not met.
a. User
as age between 18 and 55
b. User
stays has income between Rs. 50000-Rs.100000 per month
c. User
stays in Pune /Mumbai /Bangalore /Chennai
d. User
has 4 –wheeler
Accept age , income, city, vehicle from the user and check for the
condition mentioned above. If any of
the condition not met then throw the exception.
|
|
11
|
Write a menu driven program that will create data file containing the
list of telephone in the following form
John 23456
Ahmed 9876
………… ……..
Use a class object to store each set of data, access the file created
an implement the following tasks
I.
Determine the telephone number of specified
person
II.
Determine the name if telephone number is
known
III.
Update the telephone number, whenever there is
change.
|
|
12
|
Write a C++ program that creates an output file, writes information
to it, closes the file and open it again as an input file and read the
information from the file.
|
|
13
|
Using standard template library (STL) list container implement
following member functions of list class: empty, insert, merge, reverse,
sort, unique using iterator.
|
|
14
|
Writ a function template selection sort. Write a program that inputs,
sorts and outputs an int array and a float array.
|
|
15
|
Design an E-mail verifier which accepts the email address from the
user. Depending upon the input given by user display appropriate result. Use
the following concepts in the project- Constructor, Destructor, new, delete, exceptional handling, string handling functions, etc.
|
SE Computer Program Forum (OOP)
Tuesday, 23 August 2016
OOP Practical List
PR: 03 Write a program to create four-function calculator using C++
Write a program to create four-function calculator using
C++. The Program should ask the user to enter a number, an operator, and
another number.(use floating point.) It should then carry out the specified
arithmetical operation: adding, subtracting, multiplying, or dividing the two
numbers. Use a switch statement to select the operation. Finally, display the
result. When it finishes the calculation, the program should ask whether the
user wants to do another calculation. The response can be _y’ or _n’. some
sample interaction with the program might look like this:
Enter first number, operator, second number: 10/3
Answer=3.333333
Do another(y/n)?y
Enter first number, operator, second number: 12+100
Answer=112
Do another(y/n)?yProgram:
#include<iostream>
#include<stdlib.h>
#include<math.h>
using namespace std;
class calc
{
float a,b,result;
char op;
public:
void operation()
{
cout<<"\n Enter expression(First number operator second number):";
cin>a>>op>>b;
switch(op)
{
case'+':
result=a+b:
cout<<"\n Result: "<<result;
break;
case'-':
result=a-b;
cout<<"\n Result: "<<result;
break;
case'*':
result=a*b;
cout<<"\n Result: "<<result;
break;
case'/':
result=a/b;
cout<<"\n Result: "<<result;
break;
}
}
};
int main()
{
calc c;
char ch;
cout<<"\n calculator";
do
{
c.operation();
cout<<"\n Do you want to perform another operation (y/n): ";
cin>>ch;
}while(ch=='y'|ch=='Y');
return 0;
}
Subscribe to:
Comments (Atom)