Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help creating the following code Bottle(double, const char *); // parameter constructor Bottle( ); // default constructor double fill(double); double fullness( ); void display(

image text in transcribedimage text in transcribed

image text in transcribedimage text in transcribed

Need help creating the following code

Bottle(double, const char *); // parameter constructor Bottle( ); // default constructor double fill(double); double fullness( ); void display( ); double operator++(int); // postfix version double operator--(int); // postfix version 

SPECIFICATIONS: Create a C++ class called a "Bottle" that stores a double and a string no more that 30 characters long. The Bottle class MUST be prototyped exactly as listed below: class Bottle { private: // PRIVATE member data char units [31]; double capacity, amount; public: // PUBLIC member functions Bottle (double, const char *); // parameter constructor Bottle(); 11 default constructor double fill(double); double fullness(); void display(); double operator++(int); // postfix version double operator--(int); // postfix version Develop and code a class, named Bottle, with the following publicly accessible characteristics: PART 1 : Constructors When an instance of a Bottle is created, a double (indicating the capacity of the Bottle) and a constant character string (indicating the unit of capacity, max. 30 characters) may be supplied. NOTE: To indicate that a string is accepted as constant, the keyword: "const" is used. If no parameters are supplied when creating a Bottle, then the Bottle's capacity should be set to 8.00 and the units to "Litre". All new Bottle's start out empty. NOTE: 2 overloaded constructors MUST also be coded for this class (see below). PART 2: There is a member function: double fill(double) which is passed an amount to be poured into the bottle. This amount is added to the amount already in the Bottle, unless the total would exceed the capacity of the Bottle, in which case only enough to fill the Bottle is added. The amount left over, if any, is returned. PART 3: There is a member function: double fullness() which returns, as a percent, how full the Bottle is. PART 4: There is a member function: void display ( ) which displays the current state of the Bottle, in the following format: This 5.00 Litre bottle has 4.50 Litres in it. (where this particular Bottle has a capacity of 5.00, a unit of "Litre" and has had 4.5 poured into it). NOTE: All output MUST use the C++ method to display output (using cout #include using namespace std; int main() { Bottle x(3.5, "Gallon"), y; double spill = 0; while (spill == 0) { spill = x.fill(0.75); x.display(); } cout 0.00) { y--; y.display(); cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

How can you defend against SQL injection attacks?

Answered: 1 week ago