C Simple work : 3 hours
PART 2: (20 points)
Notes:
1. Each fill in the blank is worth 1 point.
2. You must use the square root function in this program.
3. All unreadable answers will be counted as wrong.
4. The answers will be graded as all right or all wrong, which includes spelling, punctuation, etc.
5. You must write the answers like you were typing a C program.
6. You cannot change variables or alter the program structure.
7. You must use standard ANSI C code. You cannot use C++ code in any portion of the program.
8. You cannot insert extra C code into the program.
PROBLEM:
The equation for computing the maximum cornering speed (tip-over speed) is:
where:
maxspeed is in mph,
corner radius is in feet,
track width is in feet,
and CG height is in feet.
This is theoretical only in that it requires the car not to spin out or slide off the road. If the tires hold the car on the radius of the turn used in the calculation, then the maximum speed can be experimentally verified. Notice that the weight of the vehicle doesn't have anything to do with the tip-over speed. It is all determined by track width (measured across the vehicle from the centers of the tires), center of gravity (CG), and the corner radius.
Complete the C program given below by filling in the missing portions. The input file is called vehicle.txt and contains the vehicle’s track width value and the radius of the turn value separated by a comma. The center of gravity changes from 0.5 feet to 3.5 feet by increments of 0.25 feet. A table containing the maximum theoretical speeds for a vehicle with changing CG heights is shown below.
PROGRAM DESCRIPTION:
This program computes the maximum cornering speed for a sport
utility vehicle as the center of gravity height, in feet above
the ground, changes from low to high. The results are printed to
the computer screen.
DESCRIPTION OF VARIABLES:
NAME | TYPE | DESCRIPTION
----------------------------------------------------------------
maxspeed | double | maximum speed before rollover in mph
corner_radius | double | corner radius of the turn in feet
track_width | double | distance measured across the vehicle
from the centers of the tires in feet
cg_height | double | center of gravity height above ground
in feet
*****************************************************************/
/* Preprocessor directives */
#include <stdio.h>
#include <math.h>
#define inputfile "u:\\engr 200\\_______________"
/* Main function */
int main(void)
{
/* Declare and initialize variables */
double _______________, _______________, _______________,
_______________;
FILE *vehicle;
/* Open input file */
vehicle = fopen(_______________,__________);
/*Verify input file and read values */
if(vehicle _____ __________)
{
printf("\n\nError opening input file\n\n"
"Program terminated\n\n");
printf("\n\n\nPress Enter to quit.\n");
getchar(); getchar();
return 0;
}
else
fscanf(vehicle,__________,_______________,_______________);
/* Compute and print results */
printf("************************\n");
printf("\nROLLOVER SPEED RESULTS\n\n");
printf("\nTrack width: %3.1f feet",track_width);
printf("\nTurn radius: %4.1f feet",corner_radius);
printf("\n\nCG Height Max Speed");
printf("\n (feet) (mph)");
while( _______________ <= _____ )
{
maxspeed = __________________________________________________
printf("\n %4.2f %4.2f",
______________,_______________);
__________ = _______________ + __________;
}
printf("\n\n************************\n\n");
/* Close input file */
fclose(vehicle);
/* Exit program */
printf("\n\n\nPress Enter to quit.\n");
getchar(); getchar();
return 0;
}
/***************************************************/
4