Most engineering products are composed of many different components or parts. It is, of course, essential to maintain a list of all parts in a product; depending on the nature of the product, one would want to include different types of information in such a list. Let's imagine that we are primarily interested in the mass and center-of-gravity of a particular product (the obvious examples are airplanes and boats, but could also include things like hand-held devices). The file vehicle.prt contains a list of part data for a particular product (a vehicle of sorts in this case). The first line contains an integer of how many different parts are in the file (i.e., the number of lines that follow). The following lines contain, in order: the part identifier number (integer); the mass m of the part (float, in kg); and the æ, y and z coordinates of where the part is located (3 floats, in m). We are going to store the information for each part in a C++ structure defined as struct Part { int id; float mass; float coord [3] ; }; We are then going to store the information for the full vehicle in an array of Part structures called parts. Using this structure, you should write a program that opens the vehicle.prt file, finds the number of parts, and allocates an array parts of the correct length. It should then read all the parts information in the file and store this in the parts array. The program should then compute the total mass and the center-of-gravity ("CG"), and also find which part is farthest from the CG. These tasks should be performed in functions, i.e., the main program should have the following exact lines of code: float xcg[3]; float totalMass - findcG (parts, N, xcg); int part_id - findFarthestItem(parts, N, xcg); The findCG function should take the parts array loaded from the file and compute both the total vehicle mass and the location of the center-of-gravity. The latter is a thrce-element vector XCG = mrotal where m, is the mass of each part, x, is the three-element vector specifying the location of each part, and motal = EN, m, is the total mass of the vehicle. The function prototype is therefore
Most engineering products are composed of many different components or parts. It is, of course, essential to maintain a list of all parts in a product; depending on the nature of the product, one would want to include different types of information in such a list. Let's imagine that we are primarily interested in the mass and center-of-gravity of a particular product (the obvious examples are airplanes and boats, but could also include things like hand-held devices). The file vehicle.prt contains a list of part data for a particular product (a vehicle of sorts in this case). The first line contains an integer of how many different parts are in the file (i.e., the number of lines that follow). The following lines contain, in order: the part identifier number (integer); the mass m of the part (float, in kg); and the æ, y and z coordinates of where the part is located (3 floats, in m). We are going to store the information for each part in a C++ structure defined as struct Part { int id; float mass; float coord [3] ; }; We are then going to store the information for the full vehicle in an array of Part structures called parts. Using this structure, you should write a program that opens the vehicle.prt file, finds the number of parts, and allocates an array parts of the correct length. It should then read all the parts information in the file and store this in the parts array. The program should then compute the total mass and the center-of-gravity ("CG"), and also find which part is farthest from the CG. These tasks should be performed in functions, i.e., the main program should have the following exact lines of code: float xcg[3]; float totalMass - findcG (parts, N, xcg); int part_id - findFarthestItem(parts, N, xcg); The findCG function should take the parts array loaded from the file and compute both the total vehicle mass and the location of the center-of-gravity. The latter is a thrce-element vector XCG = mrotal where m, is the mass of each part, x, is the three-element vector specifying the location of each part, and motal = EN, m, is the total mass of the vehicle. The function prototype is therefore
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
I want to know how to write this C++ code with comments to help me understand better.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 5 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY