Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[IN C WITH COMMENTS ]1 Question 1 A point mass consists of a 3-D location and an associated mass, such as Location: (6, 0, 2)

[IN C WITH COMMENTS ]1 Question 1 A point mass consists of a 3-D location and an associated mass, such as Location: (6, 0, 2) Mass: 3g In a system of point masses, let p1, p2, ..., pn be the n 3-D points and m1, m2, ....mn be their associated masses. If m is the sum of the masses, the center of gravity C is calculated a C = 1 m (m1p1 + m2p2 + ...... + mnpn) Write a program that repeatedly inputs point-mass system data sets from an input file until an input operation fails. For each data set, display the location matrix, the mass vector, n , and the center of gravity. Each data set includes a location matrix (a matrix in which each row is a point), a one-dimensional array of masses, and the number of point masses, n. Allow n to vary from 3 to 10. Sample Data File 4 5 -4 3 2 4 3 -2 5 -4 -3 -1 2 -9 8 6 1 This sample should be stored as: location 5 -4 3 4 3 -2 -4 -3 -1 -9 8 6 mass 2 5 2 1 1 n 4 Your main function should repeatedly input and process data sets from an input file until end of file is encountered. For each point-mass system data set, display the location matrix, the mass vector, n , and the center of gravity. Implement at least the following functions: fget point mass : Takes an open input file and a maximum value for n as parameters and fills a two-dimensional array output parameter with a location matrix and a one-dimensional array output parameter with a mass vector from the data file. Returns as function value the actual value of n. center grav : Takes a location matrix, mass vector, and n value as parameters, and calculates and returns as the function value the center of gravity of the system. fwrite point mass : Takes an open output file and the location matrix, mass vector, and n value of a point-mass system as parameters and writes the system to the file with meaningful labels. For the above sample, the output file should contain: x y z m 5 -4 3 2 4 3 -2 5 -4 -3 -1 2 -9 8 6 1 Total mass: 10.000 Center of Gravity: Cx Cy Cz 1.300 0.900 0.000 For the function center grav(), the center of gravity has three values. Thus, make the center of gravity a one-dimensional array of length 3. Do not include a return statement inside this function. For the function fwrite point mass() pass the center of gravity (a one-dimensional array of length 3) as an input parameter

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

=+Have you acquired the ability to read,

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago