Class Policy


HOMEWORK SOLUTIONS

Professional presentation of homework assignments is required. Professional presentation consists of neat and organized solution of problems on one side of 8.5"x11" papers. Any homework not complying with professional standards will not be graded and will be assigned zero credit.

Late homework assignments will not be accepted.


COMPUTER PROGRAM SOLUTIONS

Assignments involving the creation of C and Java programs will be an important component of the course. Ample time for their completion will be given. The format for handing in programming assignments is:

  1. A complete listing of the program,
  2. A listing of the input,
  3. A listing of the program output.

The grading of programs will be based on a good program design, accuracy of the results, the programming techniques used to obtain the solutions, and the ease of understanding of the output, and of course, programming documentation.

Documentation. All computer programs must be well documented. Documentation includes a description of purpose of the main program. Often it is a good idea to label the input and output parameters from each function. For example:

/*
 *  ========================================================================
 *  Solve Quadratic Equations : Coefficients are read in from keyboard
 *                            : Roots of Quadratic are printed to screen.
 *                                                                     
 *  Note : Naive implementation of quadratic equation solver. This algorithm
 *         does not take into account possible loss of accuracy when two
 *         floating point numbers of almost equal size are subtracted.
 *                                                                     
 *  Written By : Mark Austin                                    January 1999                                   
 *  ========================================================================
 */

#include    /* Standard Input/Output function declarations */
#include     /* Math functions, such as sqrt(x).            */

/* Function Declarations */

float discriminant( float , float , float );
void  quadratic ( float , float , float );

/* Main Program for Quadratic Equation Solver */

int main( void ) {
float   fA, fB, fC;          /* Coefficients for Quadratic Equation      */

   /* [a] : Print Welcome Message */

   printf("Welcome to the Quadratic Equation Solver (Version 1)\n");
   printf("====================================================\n");

   /* [b] : Prompt User for Coefficients of Quadratic Equation */

   printf("Please enter coefficients for equation a.x^2 + b.x + c\n");
   printf("Enter coefficient a : ");
   scanf("%f%*c", &fA);
   printf("Enter coefficient b : ");
   scanf("%f%*c", &fB);
   printf("Enter coefficient c : ");
   scanf("%f%*c", &fC);

   /* [c] : Print Quadratic Equation to Screen */

   printf("Equation you have entered is : %g.x^2 + %g.x + %g\n", fA, fB, fC);

   /* [d] : Compute Roots of Quadratic Equation */

   quadratic ( fA, fB, fC );
   return (0);
}

/*
 *  ======================================================================
 *  quadratic() : Compute roots to Quadratic Equations
 *
 *  Input  : float fA -- Coefficient "fA" in Quadratic equation
 *           float fB -- Coefficient "fB" in Quadratic equation
 *           float fC -- Coefficient "fC" in Quadratic equation
 *  Output : void
 *  ======================================================================
 */

void quadratic ( float fA, float fB, float fC ) {
float fRoot1, fRoot2;       /* Real Roots 1 and 2 of Quadratic Equation */
float  fDiscriminant;       /* Discriminant of Quadratic                */

   /* [a] : Compute Roots of simplified equations : fA equals zero      */

   if(fA == 0 && fB == 0) {
      printf("Cannot Solve Extremely Degenerate Equation %14.8g = 0.0\n",
              fC );
      exit (1);
   }

   if(fA == 0 && fB != 0) {
      fRoot1 = - fC/fB;
      printf("Degenerate Root : Root = %14.8g\n", fRoot1 );
      exit (1);
   }

   /* [b] : Compute Roots of Quadratic Equation : fA not equal to zero */

   fDiscriminant = discriminant( fA, fB, fC );
   if(fDiscriminant >= 0) { /* Case for Two Real Roots */

      fRoot1 = -fB/2.0/fA - sqrt( fDiscriminant )/2.0/fA;
      fRoot2 = -fB/2.0/fA + sqrt( fDiscriminant )/2.0/fA;

      printf("Two Real Roots : Root1 = %14.8g\n", fRoot1 );
      printf("               : Root2 = %14.8g\n", fRoot2 );
   } else {                   /* Case for Complex Roots */

      printf("Two Complex Roots : Root1 = %14.8g + %14.8g i\n", -fB/2.0/fA,
              sqrt( -fDiscriminant )/2.0/fA);
      printf("                  : Root2 = %14.8g + %14.8g i\n", -fB/2.0/fA,
             -sqrt( -fDiscriminant )/2.0/fA);
   }
}

/*
 *  =======================================================================
 *  discriminant() : Function to compute discriminant of Quadratic Equation
 *
 *  Input  : float fA -- Coefficient "fA" in Quadratic equation
 *           float fB -- Coefficient "fB" in Quadratic equation
 *           float fC -- Coefficient "fC" in Quadratic equation
 *  Output : float    -- Numerical value of discriminant.
 *  =======================================================================
 */

float discriminant( float fA, float fB, float fC ) {
float fDiscriminant;

      fDiscriminant = fB*fB - 4.0*fA*fC;
      return(fDiscriminant);
}

General Advise. Good programming logic is more easily acquired after you have obtained a good general knowledge a language's syntax. So spend some extra time early in the semester to learn the syntax of Matlab.

And don't leave assignments to the last minute, especially the computer programs. The concepts in this course are rather straightforward; however, significant amounts of time may still be required to solve problems and write computer programs.


EXAMINATION AND GRADING POLICY

Credit for this course for this course will be assigned as follows:

Note. All students must take at leaset on midterm exam. All students must take the final exam. There will be no makeup exams. Only extenuating circumstances will be accepted as excuse for missing an exam. Health related excuses require medical reports and the signature of a physician that provided treatment.


Developed in January 1997 by Mark Austin
Copyright © 1997-2002, Department of Civil and Environmental Engineering, University of Maryland