Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I've recently been working on this code however there appear to be a few problems I can't quite figure out: When putting in my code,

I've recently been working on this code however there appear to be a few problems I can't quite figure out: When putting in my code, the # of crates that can fit in the storage space is different from the example that I'm following. And I can't figure out how to follow the example on Example 9 when having the code say:

2094 crates can fit in the storage space.

Crate volume 12.000000 cost......................$2.50 per crate

Price to ship 294 crates........................$735.00

Storage rooms with volume 4500.000000 cost.....$0.12 per cubic foot

4500.000000 cubic feet storage room cost.......$540.00

Total cost.......................................$1275.00

Please do help. Here is my current code:

#include #include #include #include #include

using namespace std;

#define MIN_CRATE 1 // Minimum size a shipping crate can be (in feet) #define MAX_CRATE 5 // Maximum size a shipping crate can be (in feet) #define MIN_ROOM 10 // Minimum size a storage room can be (in feet) #define MAX_ROOM 100 // Maximum size a storage room can be (in feet) #define S_CRATE_RATE 2.50 // Cost to ship crate 1-40 cubic feet #define M_CRATE_RATE 3.00 // Cost to ship crate 40-80 cubic feet #define L_CRATE_RATE 3.50 // Cost to ship crate 80+ cubic feet #define S_ROOM_RATE 0.12 // Cost to ship in room 1,000-250,000 cubic feet #define M_ROOM_RATE 0.09 // Cost to ship in room 250,000-500,000 cubic feet #define L_ROOM_RATE 0.07 // Cost to ship in room 500,000-750,000 cubic feet #define XL_ROOM_RATE 0.05 // Cost to ship in room 750,000+ cubic feet

int main() { double crateLength,crateWidth,crateHeight,spaceLength,spaceWidth,spaceHeight,crateVolume,spaceVolume,crateSurfaceArea,spaceSurfaceArea,crateDiagonal,spaceDiagonal,storageSpace,room; cout >crateLength; if((crateLengthMAX_CRATE)) { cout>crateWidth; if((crateWidthMAX_CRATE)) { cout> crateHeight; if((crateHeightMAX_CRATE)) { cout > spaceLength; if((crateLengthMAX_CRATE)) { cout >spaceWidth; if((crateWidthMAX_CRATE)) { cout>spaceHeight; if((crateHeightMAX_CRATE)) { cout

crateVolume=crateLength*crateWidth*crateHeight; if(crateVolume

spaceVolume=spaceLength*spaceWidth*spaceHeight; if(spaceVolume

crateSurfaceArea=(crateWidth*crateLength+crateHeight*crateLength+crateWidth*crateHeight)*2; spaceSurfaceArea=(spaceWidth*spaceLength+spaceHeight*spaceLength+spaceWidth*spaceHeight)*2 ; crateDiagonal=crateLength*crateLength+crateWidth*crateWidth+crateHeight*crateHeight; crateDiagonal=sqrt(crateDiagonal); spaceDiagonal=spaceLength*spaceLength+spaceWidth*spaceWidth+spaceHeight*spaceHeight; spaceDiagonal=sqrt(spaceDiagonal); storageSpace=(spaceLength/crateLength)*(spaceWidth/crateWidth)*(spaceHeight/crateHeight);

for(int i=0;i

}

image text in transcribedimage text in transcribedimage text in transcribed

rooms Part 1 The transcontinental shipping company you work for has noticed some bugs in the previous program you built and now they want you to go in and fix them. They noticed your program can take in dimensions that are less than 0, and larger than any crate/room on a ship could ever be. They also noticed that if you accidentally don't enter a number into your program, it keeps running and gives them incorrect answers. They want you to go back and fix these problems in your program you previously built. Add to your previous program: 1. 4 global constants to restrict the sizes of the boxes and (limits for length/width/height): CARGO_SIZE_MINIMUM = 1 // Minimum size a shipping crate can be (in feet) CARGO_SIZE_MAXIMUM = 5 // Maximum size a shipping crate can be (in feet) STORAGE_ROOM_SIZE_MINIMUM = 10 // Minimum size a storage room can be (in feet) STORAGE_ROOM_SIZE_MAXIMUM = 100 // Maximum size a storage room can be (in feet) 2. The following error checking for each length/width/height input for the shipping crates: a. If the user enters something that isn't a double, output an error message and quit your program. b. If the user enters a value less than CARGO_SIZE_MINIMUM, output an error message and quit your program. c. If the user enters a value greater than CARGO_SIZE_MAXIMUM, output an error message and quit your program. (See the example executions 1-8 for error formatting. Note not every condition is checked for every input in the example output, but your program must account for all the conditions for each input.) 3. The following error checking for each length/width/height input for the storage rooms : a. If the user enters something that isn't a double, output an error message and quit your program. b. If the user enters a value less than STORAGE_ROOM_SIZE_MINIMUM, output an error message and quit your program. c. If the user enters a value greater than STORAGE_ROOM_SIZE_MAXIMUM, output an error message and quit your program. Part 2 Once you have these problems fixed they want you to go in and add some functionality to the program so that the program can help to quote prices to customers. They charge their customers different prices based on the volume of the crates to be shipped and the volume of the storage room to hold the crates. The pricing scheme they charge their customers is: Crate Volume Price Storage Space Volume Price 1-40 cubic feet $2.50/crate 1,000-250,000 cubic feet S.12 cubic foot 40-80 cubic feet $3.00/crate 250,000-500,000 cubic feet S.09/cubic foot 80+ cubic feet $3.50/crate 500,000-750,000 cubic feet 5.07/cubic foot Table 1: Prices to ship at crates based on 750,000+ cubic feet S.05/cubic foot crate volume. Table 2: Prices to charge per crate Add to your program: 1. 7 global constants to represent the 3 crate rates and 4 room rates: 2. CRATE_FEE_SMALL = 2.5 // Cost to ship crate 1-40 cubic feet b. CRATE_FEE_MEDIUM = 3.0 // Cost to ship crate 40-80 cubic feet c. CRATE_FEE_LARGE = 3.5 // Cost to ship crate 80+ cubic feet d. STORAGE_ROOM_FEE_SMALL = 0.12 // Cost to ship in room 1,000-250,000 cubic feet e. STORAGE_ROOM_FEE_MEDIUM = 0.09 //Cost to ship in room 250,000-500,000 cubic feet 2. STORAGE_ROOM_FEE_LARGE = 0.07 // Cost to ship in room 500,000-750,000 cubic feet g. STORAGE_ROOM_FEE_EXTRA_LARGE = 0.05 // Cost to ship in room 750,000+ cubic feet 2. The ability to choose which crate rate (la, lb, or 1c) is appropriate for the volume of the shipping crate entered by the user (you should have this entry from the previous assignment). To do this, test the volume of the shipping crate against the crate volume ranges in Table 1 using if...else statements. 3. The ability to choose which room rate (ld, le, if, or lg) is appropriate for the volume of the storage space entered by the user (you should have this entry from the previous assignment). To do this, test the volume of the storage space against the space volume ranges in Table 2 using if...else statements. 4. A calculation of how much it costs to ship the amount of crates that fit in the storage room. To do this multiply the rate from (2) by the amount of crates that fit in the storage space (you should have the amount of crates that fit in the storage space from the previous assignment). 5. A calculation of how much it costs to ship in the storage room based on it's volume. To do this multiply the rate from (3) by the storage space's volume (you should have the space's volume from the previous assignment). 6. A calculation of the total cost. To do this add the numbers from (4) and (5). 7. Output, in a nice format, of the numbers from (2) through (6). See the Example Executions for formatting. Example 9 Alexs-i Mac:as4 alex$ ./a.out SHIPPING CRATE Enter length of the shipping crate Enter width of the shipping crate Enter height of the shipping crate STORAGE SPACE Enter length of the storage space **15 Enter width of the storage space **20 Enter height of the storage space **15 TYPE | LENGTH WIDTH | HEIGHT | VOLUME | SURFACE AREA | DIAGONAL | Crate 2.0 Space | 15.0 | 3.0 I 20.0 | 2.0 115.0 | 12.0 | 4500.0 | 32.0 | 1650.0 I 29.2 294 crates can fit in the storage space. Crate volume 12.000000 cost. Price to ship 294 crates.. Storage rooms with volume 4500.000000 cost. 4500.000000 cubic feet storage room cost. . $2.50 per crate $735.00 $0.12 per cubic foot $540.00 Total cost.. $1275.00

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

Step: 3

blur-text-image

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

Database And Expert Systems Applications Dexa 2022 Workshops 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 In Computer And Information Science 33

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Alfred Taudes ,Atif Mashkoor ,Johannes Sametinger ,Jorge Martinez-Gil ,Florian Sobieczky ,Lukas Fischer ,Rudolf Ramler ,Maqbool Khan ,Gerald Czech

1st Edition

3031143426, 978-3031143427

More Books

Students also viewed these Databases questions

Question

Today, a contract without consideration may still be enforced.

Answered: 1 week ago

Question

Distinguish between hearing and listening.

Answered: 1 week ago

Question

Use your voice effectively.

Answered: 1 week ago