# include # include # include # include # include # include using namespace std; # include "ellipsoid.h" int main ( ); void ellipsoid_area_test ( ); void ellipsoid_volume_test ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // ellipsoid_test() tests ellipsoid(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 05 January 2022 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "ellipsoid_test():\n"; cout << " C++ version\n"; cout << " Test ellipsoid().\n"; ellipsoid_area_test ( ); ellipsoid_volume_test ( ); // // Terminate. // cout << "\n"; cout << "ellipsoid_test():\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void ellipsoid_area_test ( ) //****************************************************************************80 // // Purpose: // // ellipsoid_area_test() tests ellipsoid_area(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 06 January 2022 // // Author: // // John Burkardt // { double a; double b; double c; double area; cout << "\n"; cout << "ellipsoid_area_test():\n"; cout << " ellipsoid_area() computes the surface area of an ellipsoid\n"; cout << " satisfying the equation:\n"; cout << " (x/a)^2+(y/b)^2+(z/c)^2=1\n"; cout << "\n"; cout << " A B C Area\n"; cout << "\n"; a = 1.0; b = 0.8; c = 0.625; area = ellipsoid_area ( a, b, c ); cout << " " << setw(10) << a << " " << setw(10) << b << " " << setw(10) << c << " " << setw(10) << area << "\n"; a = 1.0; b = 1.0; c = 0.5; area = ellipsoid_area ( a, b, c ); cout << " " << setw(10) << a << " " << setw(10) << b << " " << setw(10) << c << " " << setw(10) << area << "\n"; a = 1.0; b = 1.0; c = 1.0; area = ellipsoid_area ( a, b, c ); cout << " " << setw(10) << a << " " << setw(10) << b << " " << setw(10) << c << " " << setw(10) << area << "\n"; a = 2.0; b = 1.0; c = 0.25; area = ellipsoid_area ( a, b, c ); cout << " " << setw(10) << a << " " << setw(10) << b << " " << setw(10) << c << " " << setw(10) << area << "\n"; a = 2.0; b = 3.0; c = 4.0; area = ellipsoid_area ( a, b, c ); cout << " " << setw(10) << a << " " << setw(10) << b << " " << setw(10) << c << " " << setw(10) << area << "\n"; return; } //****************************************************************************80 void ellipsoid_volume_test ( ) //****************************************************************************80 // // Purpose: // // ellipsoid_volume_test() tests ellipsoid_volume(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 06 January 2022 // // Author: // // John Burkardt // { double a; double b; double c; double volume; cout << "\n"; cout << "ellipsoid_volume_test():\n"; cout << " ellipsoid_volume() computes the volume of an ellipsoid\n"; cout << " satisfying the equation:\n"; cout << " (x/a)^2+(y/b)^2+(z/c)^2=1\n"; cout << "\n"; cout << " A B C Volume\n"; cout << "\n"; a = 1.0; b = 0.8; c = 0.625; volume = ellipsoid_volume ( a, b, c ); cout << " " << setw(10) << a << " " << setw(10) << b << " " << setw(10) << c << " " << setw(10) << volume << "\n"; a = 1.0; b = 1.0; c = 0.5; volume = ellipsoid_volume ( a, b, c ); cout << " " << setw(10) << a << " " << setw(10) << b << " " << setw(10) << c << " " << setw(10) << volume << "\n"; a = 1.0; b = 1.0; c = 1.0; volume = ellipsoid_volume ( a, b, c ); cout << " " << setw(10) << a << " " << setw(10) << b << " " << setw(10) << c << " " << setw(10) << volume << "\n"; a = 2.0; b = 1.0; c = 0.25; volume = ellipsoid_volume ( a, b, c ); cout << " " << setw(10) << a << " " << setw(10) << b << " " << setw(10) << c << " " << setw(10) << volume << "\n"; a = 2.0; b = 3.0; c = 4.0; volume = ellipsoid_volume ( a, b, c ); cout << " " << setw(10) << a << " " << setw(10) << b << " " << setw(10) << c << " " << setw(10) << volume << "\n"; return; } //****************************************************************************80 void timestamp ( ) //****************************************************************************80 // // Purpose: // // timestamp() prints the current YMDHMS date as a time stamp. // // Example: // // 31 May 2001 09:45:54 AM // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 19 March 2018 // // Author: // // John Burkardt // { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct std::tm *tm_ptr; std::time_t now; now = std::time ( NULL ); tm_ptr = std::localtime ( &now ); std::strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr ); std::cout << time_buffer << "\n"; return; # undef TIME_SIZE }