Question

Skills Needed: cin, cout, constants, arithmetic expressions, rounding, int main, meaningful variable names, spacing, indentation, documentation,...

Skills Needed: cin, cout, constants, arithmetic expressions, rounding, int main, meaningful variable names, spacing, indentation, documentation, output.

Computing Basic Geometric Formulas

Write a program to compute answers to some basic geometry formulas. The program prompts the user to input a length (in centimeters) specified as a floating point value. The program then echoes the input and computes areas of squares and circles and the volume of a cube. For the squares, you will assume that the input length value is the length of a side. For the circles, this same value becomes the diameter. Use the meter value input to calculate the results in square (or cubic) meters and then print the answers in square (or cubic) meters.

Area of a square (length times width)

Area of a circle (pi times radius squared)

How much bigger the area of the square is than the circle (see previous calculations)

Round the length down to the next whole number of meters, compute the volume of a cube with this value as the length of its side

Round the length up to the next whole number of meters, compute the volume of a cube with this value as the length of its side.

You are to run the program three times using the following input values:

1000

1999.9

299.4

Please turn in the program and the outputs of running the program three times as directed. Be sure to use good style, appropriate comments and make use of constants in this program.

Important Notes

For the constant PI, please use 3.14159

Use the floor() and ceil() functions to round down and up respectively. For example, ceil(3.02) is 4.

Be sure to #include to get access to these two functions

Sample Output

Your output format should look similar in style to the one below.

Geometry formulas by (Your name)

Enter one floating point number for length, 123.4

The number you entered is 123.4 cm or 12.34xx m.

Area of square xx.xxxxxxx sq. m.

Area of a circle xx.xxxxxxx sq. m.

Difference is xx.xxxxxxxx sq. m.

Cube volume rounded down is xx.xxxxxxxx cu. m.

Cube volume rounded up is xx.xxxxxxxx cu. m.

Press any key to continue

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

#include <iomanip>

#include <cmath>

#define PI 3.14159

using namespace std;

int main()

{

double lenInCm, lenInMeter;

cout << endl << "GEOMETRY FORMULAS BY (YOUR NAME)" << endl;

cout << endl << "Enter one floating point number for length: ";

cin >> lenInCm;

lenInMeter = (lenInCm / (double)100);

cout << "The number you entered is " << lenInCm << " cm or " << setprecision(4) << fixed << lenInMeter << " m." << endl;

double areaSquare = (pow(lenInMeter, 2));

cout << "Area of square " << setprecision(7) << fixed << areaSquare << " sq. m." << endl;

double radius = (lenInMeter / 2);

double areaCircle = (PI * pow(radius, 2));

cout << "Area of circle " << setprecision(7) << fixed << areaCircle << " sq. m." << endl;

double diff = (areaSquare - areaCircle);

cout << "Difference is " << setprecision(8) << fixed << diff << " sq. m." << endl;

double lenRoundDown = floor(lenInMeter);

double cubeVolumeDown = pow(lenRoundDown, 3);

cout << "Cube volume rounded down is " << setprecision(8) << fixed << cubeVolumeDown << " cu. m." << endl;

double lenRoundUp = ceil(lenInMeter);

double cubeVolumeUp = pow(lenRoundUp, 3);

cout << "Cube volume rounded up is " << setprecision(8) << fixed << cubeVolumeUp << " cu. m." << endl;

}

***************************************************************** SCREENSHOT **********************************************************

OUTPUT 1 (Input: 1000):

OUTPUT 2 (Input: 1999.9):

OUTPUT 3 (Input: 299.4):

Add a comment
Know the answer?
Add Answer to:
Skills Needed: cin, cout, constants, arithmetic expressions, rounding, int main, meaningful variable names, spacing, indentation, documentation,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Calculates thedimensions for various fish pond configurations. Specifically, theprogram will calculate the volume for...

    Calculates the dimensions for various fish pond configurations. Specifically, the program will calculate the volume for the pond in cubic feet, the surface area of the sides and bottom of the fish pond, and the area of a 2-foot wide border around the edge of the pond.Ponds come in predefined sizes and shapes.     There are:    - circular ponds, diameter: 5 feet    - square ponds, side: 5 feet     - rectangular ponds, dimensions: 4 feet by 7 feet     - ovoid ponds, dimensions:...

  • Project Objectives: To develop ability to write void and value returning methods and to call them...

    Project Objectives: To develop ability to write void and value returning methods and to call them -- Introduction: Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing the smaller tasks (calling the methods) in the correct order. This also allows for efficiencies, since the method can...

  • In C++ Amanda and Tyler opened a business that specializes in shipping liquids, such as milk,...

    In C++ Amanda and Tyler opened a business that specializes in shipping liquids, such as milk, juice, and water, in cylindrical containers. The shipping charges depend on the amount of the liquid in the container. (For simplicity, you may assume that the container is filled to the top.) They also provide the option to paint the outside of the container for a reasonable amount. Write a program that does the following: Prompts the user to input the dimensions (in feet)...

  • how to make my code of python work probely my q is how to write a...

    how to make my code of python work probely my q is how to write a code to find the average actual water level, average error by using python and my program should be flexible where user can select the column no. If you can see in the main program, it asked which column to know the maximum or average, the column number is passed to the function. The function should look which column to do. #THIS PROGRAMMING IS ABLE...

  • summarizr the followung info and write them in your own words and break them into different...

    summarizr the followung info and write them in your own words and break them into different key points.   6.5 Metering Chamber: 6.5.1 The minimum size of the metering box is governed by the metering area required to obtain a representative test area for the specimen (see 7.2) and for maintenance of reasonable test accuracy. For example, for specimens incorporating air spaces or stud spaces, the metering area shall span an integral number of spaces (see 5.5). The depth of...

  • summatize the following info and break them into differeng key points. write them in yojr own...

    summatize the following info and break them into differeng key points. write them in yojr own words   apartus 6.1 Introduction—The design of a successful hot box appa- ratus is influenced by many factors. Before beginning the design of an apparatus meeting this standard, the designer shall review the discussion on the limitations and accuracy, Section 13, discussions of the energy flows in a hot box, Annex A2, the metering box wall loss flow, Annex A3, and flanking loss, Annex...

  • Consider a cylindrical capacitor like that shown in Fig. 24.6. Let d = rb − ra...

    Consider a cylindrical capacitor like that shown in Fig. 24.6. Let d = rb − ra be the spacing between the inner and outer conductors. (a) Let the radii of the two conductors be only slightly different, so that d << ra. Show that the result derived in Example 24.4 (Section 24.1) for the capacitance of a cylindrical capacitor then reduces to Eq. (24.2), the equation for the capacitance of a parallel-plate capacitor, with A being the surface area of...

  • I have this case study to solve. i want to ask which type of case study...

    I have this case study to solve. i want to ask which type of case study in this like problem, evaluation or decision? if its decision then what are the criterias and all? Stardust Petroleum Sendirian Berhad: how to inculcate the pro-active safety culture? Farzana Quoquab, Nomahaza Mahadi, Taram Satiraksa Wan Abdullah and Jihad Mohammad Coming together is a beginning; keeping together is progress; working together is success. - Henry Ford The beginning Stardust was established in 2013 as a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT