<< Chapter < Page Chapter >> Page >
  • x, y coordinates
  • a constructor with two parameters representing x, y coordinates (their default values are allowed to be 0)
  • a member function named display, which prints out two coordinates on the screen.
  • A member function named getInfo, which accepts two input data from the user for x, y coordinates.
  • Two member functions named setX, setY to update values to x, y, respectively.
  • Two member functions named getX, getY to retrieve values from x, y, respectively.
  • A member function named distance, which accepts as parameter an object of class CPoint and calculates the distance from the object invoking the function to the parameter object.

b. Construct a derived class named CPoint_3D from the class CPoint, described as follows:

  • There is one more data member: coordinate z.
  • There are overriding member functions in CPoint_3D for all corresponding member functions in the class CPoint.

c. Include the class constructed in a) and b) in a working C++ program. Have your program call all of the member functions in the CPoint_3D class.

Programming project topic examples

Project 1

This project aims to review all the chapters from Chapter 1 (Introduction to Computers and Programming) to Chapter 6 (Functions and Pointers) which focus on structured programming.

An example of Project 1 can be described as follows:

The Colossus Airlines fleet consists of one plane with a seating capacity of 12. It makes one flight daily. Write a seating reservation program with the following features:

  • The program uses an array of 12 structures. Each structure should hold a seat identification number, a marker that indicates whether the seat is assigned and the name of the seat holder. Assume that the name of a customer is not more than 20 characters long.
  • The program displays the following menu with six choices:
    • Show the number of empty seats
    • Show the list of empty seats.
    • Show the list of customers together with their seat numbers in the order of the seat numbers
    • Assign a customer to a seat
    • Remove a seat assignment
    • Quit
  • The program successfully executes the promises of its menu. Choices (4) and (5) need additional input from the user which is done inside the respective functions.
  • After executing a particular function, the program shows the menu again, except for choice (6).

Project 2

This project aims to review all the chapters from Chapter 7 (Introduction to Classes) to Chapter 8 (Object Manipulation - Inheritance) which focus on the basics of object-oriented programming.

An example of Project 2 can be described as follows:

A stack is an ordered collection of data items in which access is possible only at one end, called the top of the stack with the following basic operations:

  • Push: add an element to the top of the stack.
  • Pop: remove and return the top element of the stack.
  • Check if the stack is empty
  • Check if the stack is full.

It would be nice to have a stack class, because we could then use it to easily develop some applications which need stack data structure.

For the moment, assume that we need to define an integer stack class. Since a stack must stores a collection of integers, we can use an integer array to model the stack and a “pointer” named Top to indicate the location of the top of the stack. The array should have a fixed size. So we can begin the declaration of the class by selection two data members:

  • Provide an integer array data member to hold the stack elements (the size of the array is a constant).
  • Provide an integer data member to indicate the top of the stack.

As for the member functions of the stack class, we have to define 5 member functions: the constructor which creates an empty stack and four other member functions (push, pop, check if the stack is empty, check if the stack is full).

After defining the stack class, write a main() function which does the following tasks:

  • Creating one stack object.
  • Pushing into the stack object ten integer elements which take values from 1 to 10 with the increment of 1.
  • Popping one by one element from the stack object and displaying it out, repeating this action until the stack becomes empty.

Next, apply the stack data structure in solving the following problem: write a program that accepts a string from the user and prints the string backward. (Hint: Use a character stack)

Questions & Answers

What is inflation
Bright Reply
a general and ongoing rise in the level of prices in an economy
AI-Robot
What are the factors that affect demand for a commodity
Florence Reply
price
Kenu
differentiate between demand and supply giving examples
Lambiv Reply
differentiated between demand and supply using examples
Lambiv
what is labour ?
Lambiv
how will I do?
Venny Reply
how is the graph works?I don't fully understand
Rezat Reply
information
Eliyee
devaluation
Eliyee
t
WARKISA
hi guys good evening to all
Lambiv
multiple choice question
Aster Reply
appreciation
Eliyee
explain perfect market
Lindiwe Reply
In economics, a perfect market refers to a theoretical construct where all participants have perfect information, goods are homogenous, there are no barriers to entry or exit, and prices are determined solely by supply and demand. It's an idealized model used for analysis,
Ezea
What is ceteris paribus?
Shukri Reply
other things being equal
AI-Robot
When MP₁ becomes negative, TP start to decline. Extuples Suppose that the short-run production function of certain cut-flower firm is given by: Q=4KL-0.6K2 - 0.112 • Where is quantity of cut flower produced, I is labour input and K is fixed capital input (K-5). Determine the average product of lab
Kelo
Extuples Suppose that the short-run production function of certain cut-flower firm is given by: Q=4KL-0.6K2 - 0.112 • Where is quantity of cut flower produced, I is labour input and K is fixed capital input (K-5). Determine the average product of labour (APL) and marginal product of labour (MPL)
Kelo
yes,thank you
Shukri
Can I ask you other question?
Shukri
what is monopoly mean?
Habtamu Reply
What is different between quantity demand and demand?
Shukri Reply
Quantity demanded refers to the specific amount of a good or service that consumers are willing and able to purchase at a give price and within a specific time period. Demand, on the other hand, is a broader concept that encompasses the entire relationship between price and quantity demanded
Ezea
ok
Shukri
how do you save a country economic situation when it's falling apart
Lilia Reply
what is the difference between economic growth and development
Fiker Reply
Economic growth as an increase in the production and consumption of goods and services within an economy.but Economic development as a broader concept that encompasses not only economic growth but also social & human well being.
Shukri
production function means
Jabir
What do you think is more important to focus on when considering inequality ?
Abdisa Reply
any question about economics?
Awais Reply
sir...I just want to ask one question... Define the term contract curve? if you are free please help me to find this answer 🙏
Asui
it is a curve that we get after connecting the pareto optimal combinations of two consumers after their mutually beneficial trade offs
Awais
thank you so much 👍 sir
Asui
In economics, the contract curve refers to the set of points in an Edgeworth box diagram where both parties involved in a trade cannot be made better off without making one of them worse off. It represents the Pareto efficient allocations of goods between two individuals or entities, where neither p
Cornelius
In economics, the contract curve refers to the set of points in an Edgeworth box diagram where both parties involved in a trade cannot be made better off without making one of them worse off. It represents the Pareto efficient allocations of goods between two individuals or entities,
Cornelius
Suppose a consumer consuming two commodities X and Y has The following utility function u=X0.4 Y0.6. If the price of the X and Y are 2 and 3 respectively and income Constraint is birr 50. A,Calculate quantities of x and y which maximize utility. B,Calculate value of Lagrange multiplier. C,Calculate quantities of X and Y consumed with a given price. D,alculate optimum level of output .
Feyisa Reply
Answer
Feyisa
c
Jabir
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Programming fundamentals in c++. OpenStax CNX. Jul 29, 2009 Download for free at http://cnx.org/content/col10788/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Programming fundamentals in c++' conversation and receive update notifications?

Ask