// SkyDivers.cpp: Calculating Velocity of a Falling Body // // Programmer: Bill McQuain // Compiler: Visual C++ 2008 // Date: June 12, 2009 // // Purpose: // To compute the velocity of a free-falling body, given // the number of seconds since its release, its weight, // and its coefficient of drag. // // Modified June 09 to use a functional decomposition. // // This file contains an edited version of my completed solution; many things // have been cut out, including: // // - some global declarations // - all of the function declarations // - the parameter lists in the function calls; but the calls themselves // are still shown // - the function implementations (of course) // #include #include #include #include using namespace std; // Any global declarations for constants would go after this comment: // Function declarations would probably go after this comment: int main() { // Declarations: string lastName, firstName; double Weight, // weight of object in pounds Mass, // mass of object Drag, // coeff of drag for object Time, // seconds object has been falling fpsV, // object velocity in feet per second mphV; // and miles per hour ifstream iFile("Input.txt"); // open input file ofstream oFile("Output.txt"); // open output file oFile << fixed << showpoint; // prepare for floating-point output // Print the header info to output file: printTableHeader(. . .); // Read first line of data from input file: // iFile.ignore(INT_MAX, '\n'); // skip header lines iFile.ignore(INT_MAX, '\n'); readTableRow(. . .); // Process lines of data until none remain: // while (iFile) { // ----------------------------------------------------------- Processing Section // create full name for printing (optional): string Name = firstName + " " + lastName; // calculate mass, using specified formula: Mass = calculateMass(. . .); // calculate velocity in feet per second, using specified formula: fpsV = calculateFPS(. . .); // convert velocity to miles per hour: mphV = calculateMPH(. . .); // --------------------------------------------------------------- Output Section // print mass, drag, time and velocity as per the project spec: printTableRow(. . .); // Try to read the next line of input: // readTableRow(. . .); } // End of while loop. printTableFooter(. . .); // Close the files: iFile.close(); oFile.close(); // Exit program: return 0; } // The implementations of the functions would go after this comment: