String-classes-constructors and member functions, C/C++ Programming

Objective

Using C++ string, classes, constructors and member functions.

Task A
Write a program (book.cpp) to store a list of book titles and the published dates. Your program is to read in an array of book titles and published dates. The student should declare a class called book with two members: book title and published date.

Your program shall perform the following:
1. Prompt user to enter the book title and the published date.
2. The program should be designed to allow the user to key in 10 entries and they should be stored in an array of structures.
3. A function printbook should be written for the 10 entries of book titles and published dates to be printed out on the screen.
4. Correctly identify invalid user input

Task B

Write a program (room.cpp) to create a room class which allows the user to set the length and width of the room as well as the colour of the room. The user can also display the room's area and colour on the screen.

The program should include the following:
• The room class consists of 3 variables: length, width and colour.
• The room class should have a function area to calculate the room area based on the length and width inputs.
• Two instances or objects: rooma and roomb of the room class should be created.
• Use constructor and destructor for the room class.
• rooma object should be declared and 3 arguments should be passed on. They are: length=5, width=4 and colour=green.
• roomb object was declared without any arguments, which initialised both length and height with a value of 4 and colour=white.
• The program should print out the area and colour of the objects (rooma and roomb).

Posted Date: 2/23/2013 2:43:29 AM | Location : United States







Related Discussions:- String-classes-constructors and member functions, Assignment Help, Ask Question on String-classes-constructors and member functions, Get Answer, Expert's Help, String-classes-constructors and member functions Discussions

Write discussion on String-classes-constructors and member functions
Your posts are moderated
Related Questions
#question.to determine the area of a triangle,rectangle and trapezium


Question 1 Describe the theory behind class templates and function templates along with relevant programming examples Question 2 With the help of suitable programming example

Explain Operators in C Language? The C language is very rich in built - in - operators and it places more significance on operators than do most other computer languages. The C

Define The Return Statement in Computer Programming? The return statement is used for two purposes once the return statement is executed the program control will be immediately

Ask question #write statement that assign random integer to the varaible n in the (100

Differences between a pointer and a reference 1.  A reference must always point to some object where as this restriction is not imposed on a pointer. e.g. int *pi = 0;



Receive 3 numbers and display them in ascending order from smallest to largest ed#