Results 1 to 1 of 1

I Need Help

This is a discussion on I Need Help within the C++ forums, part of the Courses category; Posted by: Jhaman Das Rathore (@ Sindh Agriculture University Tandojam) Make programs of these and post on................. Chapter 6 objects ...

  1. #1
    iTT Student jhrathore's Avatar
    Join Date
    Jul 2010

    Cursing C++ Programs

    Posted by: Jhaman Das Rathore
    (@ Sindh Agriculture University Tandojam)

    Make programs of these and post on.................

    Chapter 6
    objects and classes

    1. Create a class called time that has separate int member data for hours minutes, and seconds. One constructor should initilize this data to 0, and another should initilize it to fixed values. Another member function should display it in, 11:59:59 format. The final member function should add two objects of type time passed arguments.
    A main() program should create two initialized time objects (should they be const?) and one that isn't initialized. then it should add the two initialzed value together, leaving the result in the third time variable Finally it should display the value of this third variable. Make appropriate member funciton const.

    2. Imagine a tollbooth at a bridge. Cars passing by the booth are expected to pay a 50 cent toll. Mostly they do, but sometimes a car goes by without paying. The tollbooth keeps track of the number of cars that have gone by and of the total amount of money collected.

    4.create an employee class basing it on exercise 4 of chapter4. the member data should comprise an int for storing the employee number ,and a float for storing the employee's compensation .member function should allow the user to enter this data and display it.write a main() that allows the user to enter data for three employee and display it.

    5. start with the data structure in excersice 5 in chapter 4 and transform it into a data class its member data should consist three int:month,day , and year .it should also have two member function getdate(),which allow the user to enter a date in 12/31/97 format ,and showdate(),which display the date.
    Chapter 9

    1.imagine a publishing company that markets both and audiocassette versions of its works.create a class publication 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 which adds a playing time in minutes (type float).each of these three classes should have a getdata()function to get its data from the user at the keyboard,and putdata() function to display its data.write a main() program to test the book and tape classes by creating instance of them asking the user to fill in data with getdata()and then displaying the data with putdata().

    4.Assume that the publisher in exercise 1 and 3 decides to add a third way to distributes bookn computer disk, for those who like to do their reading on their laptop.add a disk class that,like book and tape is derived from publication.The disk class should incorporate the same member functions as the other classes .The data item unique to this class is the size:either 3-1/2inches or 5-1/ can use enum Bolean type to store this item but the complete size should be displayed the user could select
    the appropriate size typing 3 or 5...

    5. derive a class called employee2 from the employee class in the employ program in this chapter.this new class should add a type double data item called compensation and also an enum type called period to indicates whether the employee is paid hourly,weekly or monthly . for simplicity you can change the manger, scientist and laborer classes so they are derived from employee2 istead of employee. however note that in many cirumstance it might be more in the spirit of OOP to create a seprate base class called
    compensation and three new classes manger2 scientist2 and laborer2 and use multiple inheritance to derive these classes from the orignal manger,scientist and laborer classes and from compensation. this way none of the orignal classes needs to be modified.

    6.Start with the arrover3 program in chapter 8.keeps the safearay class the same as in that program and using inheritance ,derived the capability for the user to specify both the upper and lower bounds of the array in a constructor. this is simillar to exercise 9 in chapter 8 ,except that inheritance is used to derive a new class (you can call it safehilo) instead of modefying the orignal class........

    7.start with the counten2 program in this can increment or decrement a counter but only using prefix notation.using inheritance add the ability to use postfix notation for both incrementing and decrementing .(see chapter8 for a description of postfix notation.)

    10. there is only one kind of manger in the empmult program in this chapter .any serious company has executives as well as mangers. from the manager class derive a class called executive .(we'll assume an executive is a high-end kind of manager)..The addional data in the executive class will be the size of the employee's yearly bonus and number of shares of company stock held in his or her stock-option plan.add the appropriate member function so these data item can be input and displayed along with the other manger data.....

    chapter 10

    1.write a program that reads a group of numbers from the user and places them in an array of type float .once the numbers are stored in the array the program should average them and print the use pinter notation whereever possible.?

    2.start with the string class from the newstar example in this chapter.Add a member function called upit() that converts the string to all upper case . you can use the toupper() library function, which takes a single character as an argument and return a character that has been converted ( if necessary)to upercase. this function uses the CC type header file.
    Write some code in main () to test upit().

    3.start with an array of pointers to strings representing the days of the week as found in the pirtostr program in this chapter. provide functions to sort the string into alphabetical order using variations of the bsort() and order() function from the pitrsort program in this chapter. sort the pointers to the strings not the actual strings.........

    4.. add a destructor to the linklist program . it should delete all the links when a linklist object is destroyed. it can do this by follwing along the chain deleting each link as it goes. you can test the destructor by having it display a message each time in deletes a link ; it should delete the same number of link that were added to the list(A destructor is called automatically by the system for any existing objects when the program exits).

    Chapter 11
    Virtual function.
    10. carry out the modification, discussed in exercise7 to the parse program of chapter 10 . that is make it possible to parse expressions containting floating-point numbers combine the classes from exercise 7 with algorithm from parse. You'II need to oprate on pointers to tokens instead of characters this involves satenents of th e kind...............
    Last edited by jhrathore; 30th October 2010 at 12:04 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts