Question
In Visual Studio (.cpp file) Write a program that reads a type of metal, a density, a radius, and a height from a file named
In Visual Studio (.cpp file) Write a program that reads a type of metal, a density, a radius, and a height from a file named metals.txt. This file must be created and placed in the appropriate location so that your program can use it as an input file. The program will then compute and display the volumes and masses of two shapes, a sphere and a cone, made out of the specified metal with the specified dimensions. In addition to recalling that an objects mass is equal to its volume times its density, youll need these formulas: Volume of a sphere: = 4 3 3 , where r is the spheres radius Volume of a cone: = 2 3 , where r is the cones radius and h is its height For , use the value 3.14159. Note that although this program gets input from a file, it displays its output on the screen. A sample run is shown below, assuming that the file named metals.txt contains the following text and numbers: aluminum 2.70 5.27 10.2. The three numbers listed here represent aluminums density (in grams per cubic centimeter), a radius (in centimeters), and a height (in centimeters). Test your program thoroughly, using the values from the sample run and using other values of your own invention to make sure that all parts of your program work correctly.
**Your output should look exactly as shown below, including spelling, punctuation, capitalization, spacing, and number format.
For a sphere made of aluminum with radius = 5.27 cm:
Volume = 613.08 cubic centimeters
Mass = 1655.33 grams
For a cone made of aluminum with radius = 5.27 cm and height = 10.20 cm:
Volume = 296.65 cubic centimeters
Mass = 800.96 grams**
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started