Question:
I NEED THE CODE OF FEW PROGRAMS IN C++......PLZZZZZ....HELP ME GUYS...PLZZZ....I'LL BE VERY THANKFUL TO U GUYS?
Navin k
2009-05-08 07:52:36 UTC
QUES 1 .Create 2 classes OM and DB which store the value of distance. DM store distances in meters and cm and DB in feet and inches. Write a program that can read values for the
class objects and add 1 object OM with another object of DB. .

Use a friend function to carry out the addition operation the object that stores the results
may be a DM object or a DB object, depending upon the units in which the results are
require. The display should be in the format of feet and inches or meters and cms
depending on the object on display

QUES 2. A book shop maintains the inventory of books that are being sold at the shop the list includes details such as author, title and publisher and stock position. Whenever a customer wants the book, the sales person inputs the title and author and the system
search the list and display whether it is available ornot. If it is not, a appropriate message is displayed, if it is, then the system displays the book details and requests for the number of copies require. If the requested are available, the total cost of the required 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 constructor to allocate memory space require.

QUES 3. Define a class string that could work as a userdefined string type include constructors that will enable us to create an .un-initialized string
String s1; :/ string with length 0
And also to initialize an object with string constant at the time of creation like
String s2("well done"); .
Include a function that adds two strings to make a third string.

QUES 4. Create a base class called shape use this class to store two double type values that could be used to compute the area of fig. Derive the specific class called TRIANGLE and RECTANGLE from the data shape. Add to base class, a member function get - data ( ) to initialize base class data members and another member and another member function
display – area( ) to compute and display the area of the fig.. Make display – area ( ) as a
virtual function and redefine function in the derived classes to suit their requirements,
Using these 3 classes design a program that will accept dimension of RECTANGLE or
TRIANGLE interactivity and display the area.
Remember the 2 values given as input will be treated as length of 2 sides in the case of
rectangle and as base and height in the case of triangles and used as follows:
Area of rectangle = x*y
Area of triangle = 1/2 *x*y

QUES 5. WRITE AN INTERACTIVE OPERATOR OVERLOAD PROGRAM TO MANIPULATE MATRICES.OVERLOAD OPERATORS SUCH AS <<,>> AND + FOR OPERATIONS ON A SINGLE DIMENSION ARRAY.

QUES 6. Assume that a bank maintains two kinds of accounts for customers, one called savings account and the other as current account. The savings account provides compound interest and withdrawal facilities but no cheque book facility. The current account provides cheque book facility but no interest. Current account holders should also maintain a minimum balance and if the balance falls below this level, a service charge is imposed.
Create a class ACCOUNT that stores customer name, account number and type of account. From this derive the class CUR_ACCT and SAV_ACCT to make them more specific to their requirements.WRITE A FUNCTION TO DEPOSIT, WITHDRAW AND QUERY BALANCES.

QUES 7. write a program to manipulate N student objects.overload a subscript operator for bounds check while accessing ith student object when i>=N.

ques 8. design a single link list class having functionality to add nodes,traverse and print nodes.write a program to perform these task.

ques 9. WRITE A PROG TO COMPUTERIZE THE UNIVERSITY LIBRARY.THE LIBRARY HAS TWO TYPES OF MEMBERS:STUDENT,STAFF.THE STUDENT CAN BORROW 3 BOOKS AND THE STAFF CAN TAKE 10 BOOKS ONLY.THE DUE DATE IS 7 DAYS AND 30 DAYS FOR STAFF.IF THE BOOKS IS NOT RETURNED BY DUE DATE FINE IS PUT FOR EACH DAY.STAFF HAS NO FINE.
DESIGN COMPLETE PROG USING INHERITANCE, VIRTUAL FUNCTION,ABSTRACT CLASSES.WRITE A FUNCTION TO WITHDRAW BOOKS FROM LIBRARY.

QUES 10. WRITE A PROGRAM TO OVERLOAD 'NEW' AND 'DELETE' OPERATORS SO THAT THE MEMORY RESOURCES ARE HANDLED IN BETTER WAY.

QUES 11. WRITE A PROG TO OVERLOAD THE RELATIONAL OPERATOR <,>,== AND != TO WORK ON STRING TYPE OF OBJECT.

QUES 12. WRITE A PRO USING CLASSES TO CREATE A SINGLE LINK LIST.THE SHOULD HAVE CAPABILITY TO ADD, DELETE AND PRINT THE NODES.

QUES 13. WRITE A PROGRAM USING CLASS TEMPLATE TO SEARCH AN ELEMENT IN AN ARRAY USING BINARY SEARCH METHOD.ASSUME THAT THE ARRAY IS ALREADY SORTED.

QUES 14. CONSIDER AN EXAMPLE OF DECLEARING THE EXAMINATION RESULT.DESIGN 3 CLASS: STUDENT,EXAM AND RESULT.THE STUDENT CLASS HAS DATA MEMBERS OF STUDENT INFORMATION.CREATE A CLASS EXAM BY INHERITING STUDENT CLASS.DERIVE THE RESULT CLASS FROM EXAM CLASS AND ADD YOUR OWN DATA AND
Four answers:
cja
2009-05-08 08:36:08 UTC
You're asking for a lot, too much actually. Many of us here could code good solutions to every one of these problems, but why would we? If you're taking a course, and you have any interest in it at all, work these out yourself. There is some interesting stuff here, and some fun to be had for someone who cares about C++ and OO programming. If you don't care, perhaps you should drop the class.



Admonishments aside, I'll give you an answer to the one that was interesting to me. I hope it will motivate you to get busy on the others.



#include

#include



using namespace std;



template struct Array {

    T array[Size];

};



template

size_t len(const Array&) {

    return Size;

}



template

int binarySearch(const Array&, size_t, size_t, const T&);

template

void print(const Array&a, const string&);



const string zero("zero");

const string one("one");

const string two("two");

const string three("three");

const string four("four");



int main(int argc, char *argv[]){

    Array a1;

    Array a2;

    size_t a1Len = len(a1);

    size_t a2Len = len(a2);



    // initialize

    for (size_t i = 0; i < a1Len; i++) {

        a1.array[i] = (i+1)*10;

    }

    a2.array[0] = one;

    a2.array[1] = three;

    a2.array[2] = two;

    a2.array[3] = zero;



    // print

    print(a1,"a1");

    print(a2,"a2");



    // search

    int x = binarySearch(a1,0,a1Len-1,30);

    cout << "search for 30 in a1 returned: " << x << endl;

    x = binarySearch(a1,0,a1Len-1,99);

    cout << "search for 99 in a1 returned: " << x << endl;



    x = binarySearch(a2,0,a2Len-1,one);

    cout << "search for \"" << one;

    cout << "\" in a2 returned: " << x << endl;

    x = binarySearch(a2,0,a2Len-1,three);

    cout << "search for \"" << three;

    cout << "\" in a2 returned: " << x << endl;

    x = binarySearch(a2,0,a2Len-1,zero);

    cout << "search for \"" << zero;

    cout << "\" in a2 returned: " << x << endl;

    x = binarySearch(a2,0,a2Len-1,four);

    cout << "search for \"" << four;

    cout << "\" in a2 returned: " << x << endl;



    return 0;

}



template

void print(const Array&a, const string &s) {

    cout << s << ":" << endl;

    for (size_t i = 0; i < len(a); i++) {

        cout << "\t" << a.array[i] << endl;

    }

    cout << endl;

}



template

int binarySearch(const Array&a, size_t first, size_t last, const T &x) {

    if ((x < a.array[first]) || (x > a.array[last])) return -1;

    if (a.array[first] == x) return first;

    else if (a.array[last] == x) return last;

    int mid = (first+last)/2;

    if (x > a.array[mid]) return binarySearch(a,mid+1,last,x);

    else return binarySearch(a,first,mid,x);

}



#if 0



Program output:



a1:

                10

                20

                30

                40

                50



a2:

                one

                three

                two

                zero



search for 30 in a1 returned: 2

search for 99 in a1 returned: -1

search for "one" in a2 returned: 0

search for "three" in a2 returned: 1

search for "zero" in a2 returned: 3

search for "four" in a2 returned: -1



#endif
margarita
2016-05-28 08:33:51 UTC
break; Statement uses to end loop execution earlier. Your code is just fine, you may remove grade checking statement from the loop condition "grade>=0 &&" it's redundancy since you've already checked for negative value inside the do block "if(grade<0)". Now, because grade need to be read inside do-while loop there is no way to prevent the loop form execution (at least one time). But you can enhance your program by prevent printing output in-case of countering negative value; if(grade>=0) { average = sum / student; cout<
?
2009-05-08 08:18:00 UTC
These are very simple homework problems - you should try a nd answer tthem yourself first before asking for help - that way you may learn a little about programming etc
2009-05-09 04:09:50 UTC
R u serious?????????????????????


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...