Create-a-C-class-Rectangle-

Create-a-C-class-Rectangle- | savvyessaywriters.org

Create a C++ class Rectangle. The class has attributes length and width, with defaults to 1.0. It has member functions for calculating the perimeter and the area of a rectangle. It has setLength, setWidth, getLength, and getWidth functions for updating and accessing the length and width values. The set functions should verify that length/width are each floating-point numbers greater than 0.0 and less than 20.0. If an invalid value is encountered, the corresponding set function should return –1 to the calling function without changing the length/width values. Implement a main function that takes a data file name from command line argument. The main function reads the length and width values from this input file and use the Rectangle class to calculate the perimeter and area for each data set. (Note: the Rectangle class should not include any I/O codes. All I/Os should be done external to the Rectangle class).

Source Files:

● Rectangle.h – contains the Rectangle class declaration.

● Rectangle.cpp – contains the Rectangle class implementation.

● hw04.cpp – contains the main function and any other functions for file I/Os.


Example Output:

% cat hw04.dat

3.456 2.89

0.0 2.90

12.898 20.0

-1.234 13.234

1.0 21.345

% hw04

Usage: hw04 <file name>

% hw04 hw04.dat foobar.dat

Usage: hw04 <file name>

% hw04 hw04.dat

INPUT: Length = 3.456

Width = 2.890

PERIMETER: 12.692

AREA: 9.988

INPUT: Length = 0.000 Width = 2.900

ERROR: Invalid length: 0.000


INPUT: Length = 12.898 Width = 20.000

ERROR: Invalid width: 20.000


INPUT: Length = -1.234 Width = 13.234

ERROR: Invalid length: -1.234


INPUT: Length = 1.000 Width = 21.345

ERROR: Invalid width: 21.345


Submission:

Turn in the printout of the program and input data file with at least 3 sets of length/width values.Capture the source code and output into a single file

 

Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code “Newclient” for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.


The post Create-a-C-class-Rectangle- appeared first on Affordable Nursing Writers.