This program is for a car rental agency. Your program will have to compute the
total cost of a rental. This agency has two types of cars, and the rates per day
are as follows: All cars come with a basic insurance that covers damage to third
Driver above 25
years of age
Driver 25 years
old or younger.
Compact car $60 $80
Mid-size car $75 $100
Table 4: Price list for problem A.3
parties. Comprehensive insurance cover costs $30 for compact cars and $40 for
mid-size cars.

Recommended Answers

All 6 Replies

do you own homework, kiddo.

We all would be happy to help, once you've shown some work on your own part. We are willing to give advice, answer specific questions, and even show how to find and fix bugs. But we will not do the work for you.

Can Anyone help me understanding the bubble sort data structure? and LIFO.

First off, do not hijack an existing thread with an unrlated question. I know that the OP gave this thread an unfortunately generic title, but that isn't an invitation to discuss all aspects of C++ in it.

Second, the question is rather generic itself, and an easy answer is difficult to give, especailly since the fist question is invalid - Bubble Sort is an algorithm (that is to say, a description of how to perform a task), not a data structure (a grouping of data values in a particular manner). The main idea - one simple enough that most people find it themselves on their first try at sorting - is to repeatedly pass over the array in order, and compare each value to the one following it; if the second value is lower, you then swap the two values, and proceed. The result is that the higher values 'bubble up' to the top over successive passes.

There are many pages on the Web which explain Bubble Sort, and sorting in general, and a trivial search should find several such as this one.

A stack or LIFO queue is a data structure, but one which is used in a particular manner - it is ordered in such a way that the last item placed in it is the first one to be removed. The usual solution to making a stack is to have an array and an index indicating where the 'top' of the stack is, and you would simply increment or decrement the index to add or remove items. Again, a simple search will uncover a large number of tutorials on the subject.

@Shol-R-Lea
Well put!

@Morganstevens
Read Donald Knuth's seminal volume 3 of the "Art of Computer Programming, Sorting and Searching". I am considered an "expert" on database systems. Knuth volume 3 is where I learned the basics of the subject - that and the works of Codd and Date.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.