Calculate the volume of a slant cylinder

Assignment Help C/C++ Programming
Reference no: EM131016481

Project - Winter 2016

The purpose of this project is to write a set of functions that calculate the volume of a slant cylinder (actually a prism) with an irregular pentagonal cross section shown in Figure 1.

You will be given the coordinates of the corners of the pentagon (five pairs of x,y values), and the value h, the vertical height of the prism. You must read the file* and fill the two vectors x and y that will contain the coordinates. x and y are two one-dimensional arrays. Now, we will need to break this problem apart, writing functions to solve each part. Note that the development of these parts will not occur in order necessarily (in fact it is recommended that you write the function in part 4 first (tri_side) and then write the other ones in reverse order.

1. The volume of the prism is the area of the pentagon multiplied by the vertical height. Write a function named polyvol to solve this.

2. The area of the pentagon is the sum of the areas of three triangles as shown in Figure 2. So we need to write a function named pent_area that takes in the area of the three triangles and adds them together.

3. Given the coordinates of the corners of the triangle, we need to write a function named tri_area to calculate the area of the triangle (see Figure 3). To compute the area of the triangle, we need the values a, b, and c. So if we had the lengths of the lines, the area of the triangle is given by Heron's formula:

A = ( s(s-a) (s-b) (s-c) ) where s is half the sum of a, b, and c.

4. Then, we need a function named tri_side that computes the length of a line when given its end points. (You may need to review a bit of high school geometry to write that simple function)

5. Finally, put it all together by writing the main program that will read a data file, then call the polyvol function (and in turn, from it, the other functions) and display the volume of the prism in cubic meters. Test/run your program for each of the two data files (test cases).

Attachment:- p2.rar

Reference no: EM131016481

Questions Cloud

Determine a formula that counts the numbers of nodes : Determine a formula that counts the numbers of nodes in the recursion tree. What is Big- O for execution time? Determine a formula that expresses the height of the tree. What is the Big-O for memory?
How many times will the bell be struck in two days : If clock strikes once at one o clock, twice at two o clock, and twelve times at twelve o clock, and again one at one o clock and so on. How Many times will the bell be struck in 2 days.
Explain how non-volatile ram can help speed up disk writes : Since indexes speed up searches, why wouldn't the DBMS automatically create an index for every column of a table?
Social media and marketing technology in an essay : In this assignment, you will explore social media and marketing technology in an essay. In your essay, choose a brand (or product) that relies heavily on social media or technology to market their product. Examples would be Netflix, Uber, or Coca-..
Calculate the volume of a slant cylinder : Write a set of functions that calculate the volume of a slant cylinder (actually a prism) with an irregular pentagonal cross section - Write a function named polyvol to solve this.
How enculturation may play a role in the case study : Discuss the methodology associated with cross-cultural psychology research. Discuss how the case study helps you better understand how ethnicity, race, and worldviews are separate yet related concepts. Discuss how enculturation may play a role in the..
Improving nonverbal communication in the text : Describe a time when nonverbal communication caused you to misinterpret the message in a work situation (explain the type of nonverbal cue using the information in the text). Then, using the guidelines for improving nonverbal communication in the ..
How do we know that the eigenvalues of a are all real : How do we know that the eigenvalues of A are all real and distinct before we calculate them? Find the characteristic polynomial of A. Find the eigenvalues of A.
How is laura behavior indicative of role confusion : How is Laura's behavior indicative of role confusion as discussed by Erik Erikson's model of psychosocial development? How are her peer relationships affecting her decisions

Reviews

Write a Review

C/C++ Programming Questions & Answers

  The agricultural activities that contribute to a global

The agricultural activities that contribute to a global increase of greenhouse gases in the atmosphere.

  Add a non member function

For the code below add the following. Add a non member function that will run the show function of a Sport object. This object is the one parameter of the function.

  Consulting firm hired to develop a program

Your program must provide a menu to the user. This menu should list five different products of your choice. Once the user selects one product, they should specify which state they are located. The state choices should include CT, VT, WI, CA and WA..

  Program that calculates and prints average of several grades

Write a C program that calculates and prints the average of several grades entered by the user. The program should first prompt the user to enter the number of grades to process (at least 2 grades must be entered by user!)

  Creates a macro to calculate the area

Build a program that creates a macro to calculate the area of a circle using the formula area = pie x radius x radius. In the same program, prompt the user to enter a circle's radius. Use the macro to calculate the circle's area and display the re..

  Write a function called makemat that will receive two row

Write a function called makemat that will receive two row vectors as input arguments, and from them create and return a matrix with two rows.

  Write a program to hold an array of 20 numbers read

Write a program to hold an array of 20 numbers read in from the keyboard and display them backwards. Use a array and a loop to cycle through the numbers.

  Prepare a binary to decimal memory game

The computer generates a random sequence of 0s and 1s creating a binary number - prepare a binary to decimal memory game.

  The owner of a hardware store and need to keep an inventory

You are the owner of a hardware store and need to keep an inventory that can tell you what tools you have, how many you have and the cost of each one. Write a C program to create a file named storage.dat and write the data shown in the Table 1 into t..

  Recognize a string typed in as a valid or invalid

Use regex to recognize valid Social Security numbers.  A valid Social Security number consists of three digits, an optional hyphen, two digits, an optional hyphen, and four digits.

  What is the :: called in c++

What is the :: called in C++ when used like this std::endl; In my main file, what line of code prevents me from having to put std before every endl

  A sample of helium gas occupies 945ml at 605 mmhg

A sample of helium gas occupies 945mL at 605 mmHg. For a gas sample at a constant temperature, determine the volume of helium at 745 mmHg?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd