473,395 Members | 1,931 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Imagine a tollbooth at a bridge. Cars passing by the booth are expected to pay a 50 p

Imagine a tollbooth at a bridge. Cars passing by the booth are expected to pay a 50 pesewas 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.

Model this tollbooth with a class called tollBooth. The two data items are a type unsigned int to hold the total number of cars, and a type double to hold the total amount of money collected. A constructor initializes both of these to 0.

A member function called payingCar() increments the car total and adds 0.50 to the cash total.

Another function, called nopayCar(), increments the car total but adds nothing to the cash total.

Finally, a member function called display() displays the two totals. Make appropriate member functions const.

Include a program to test this class. This program should allow the user to push one key to count a paying car, and another to count a nonpaying car. Pushing the Esc key should cause the program to print out the total cars and total cash and then exit.
Oct 4 '12 #1
1 4453
Meetee
931 Expert Mod 512MB
This thread is closed as Bytes do not allow homework/assignment post.
Oct 4 '12 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Steven M. Scotten | last post by:
Hi-- I seem to have the PHP Java Bridge (2.0.5 built from tarball) working with PHP 5.0.3 (also built from tarball) on my Fedora Core 1 server with Apache 2.0.50 and I'm pretty excited about it...
2
by: John Leslie | last post by:
I am porting a script from Korn Shell to python and want to pass named parameters like -JOB 123456 -DIR mydir I can get it to work passing --JOB and --DIR but not -JOB and -DIR Any ideas? ...
40
by: Sonia | last post by:
Hi, Please look at the following code. This is a simple program for a game of craps - very basic. I have declared the gameStatus as global variable. I was wondering if there is a better way of...
6
by: David Cook | last post by:
The html file below gets intermittent errors 'error on page' ('number expected') when clicking on column-headings to sort. Yet, this same file works flawlessly in other browsers (i.e. Opera,...
2
by: LeTubs | last post by:
Hi I'm think I'm having some problem with pointers..... namely passing them around...Or I think ? I've used gdb to find the following (note conn is of type MYSQL *conn). Program received...
4
by: jos | last post by:
Hi There, What would be suitable options to exchange data between a Dot net program and a java program? Thanks Jyotsna Sharan
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
12
by: Adrian | last post by:
The code below was taken from an example. All the "noise" in the example was thrown out. This is supposedly according to the bridge pattern. What in the code (which lines) represent the bridge...
5
by: Keo932 | last post by:
Hello all, I am finishing up my program to simulate a tollbooth by using classes. What happens is cars passing by the booth are expected to pay a fifty cent toll. The program keeps track of the...
9
by: JRough | last post by:
I'm getting the error message that the parameter passed to the function is not a valid resource. The parameter is $result and it is from a query in a switch statement. What do I have to do to get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.