Objective:
Â
Students will display their knowledge of building and using recursive functions (and previous course topics) in programming using a real-world example.
Problem:
You have been hired by a construction firm as an engineering consultant for a rock blasting project. It is your job to make sure that the vibrational energy caused by the blasts will not result in structural damage in any buildings in the surrounding area. As part of the problem analysis, you have investigated the geological conditions of the area. Between the blast site and the nearest building, there are 12 different bands of rock of equal width â meaning the vibrational waves from the blast will travel the same distance across each band. The velocity of the waves will be affected based on the following modifiers (ordered from closest to furthest from the blast site). Note that the nearest building is situated just beyond these 12 bands of rock.
Â
[Blast site] Â Â -3% Â Â -18% Â Â +34% Â Â +0% Â Â -23% Â Â -31% Â Â +18% Â Â +3% Â Â -8% Â Â -21% Â Â -10% Â Â +25% Â Â [Nearest Building]
Your task is to create a computer program that can, based on the nearest buildingâs (arbitrary) maximum tolerable relative intensity and wave velocity, calculate the wave velocity and relative intensity of the largest possible blast. The relative intensity can be modeled with the following formula: I_0 = I_1 + d/v where I_0 is the vibration intensity in the current rock band, d is the number of rock bands between the blast site and the current band, v is the vibrational wave velocity in the current rock band, and I_1 is the vibration intensity at the next closest rock band in the direction of the building.
Â
Instructions:
Write a program in C to performing the following tasks:
In your main function, do the following:
Prompt the user to enter the maximum tolerable relative intensity and wave velocity.
Call the getVelocity function (see below) to get the maximum wave velocity at the blast site, and outputs it using the format shown in the sample solution below.Â
Call the getIntensity function (see below) to get the maximum relative intensity at the blast site, and outputs it using the format shown in the sample output below.Â
Â
Write a recursive function called getVelocity that performs the following:
    Checks if your index is beyond the final rock band (closest to the building). If true, it returns the maximum tolerable wave velocity.
    Returns the wave velocity before it passes through the current rock band (by dividing the wave velocity after passing through the current rock band by the current bandâs modifier).
  Write a recursive function called getIntensity that performs the following:
    Checks if your index is beyond the final rock band (closest to the building). If true, it returns the maximum tolerable relative intensity.
    Calls the getVelocity function to compute the wave velocity at the current rock band.
    Returns the relative intensity, I¬0, based on the equation described above (note that you will have to call getIntensity to get the relative intensity through the next closest rock band in the direction of the building).
Â
Your program will need to take user input for the buildingâs maximum tolerable values. Read this input with the scanf function, using the format shown in bold in the sample output.
Â
Comments are mandatory for this assignment. Add comments as necessary for important parts of your code, such as function calls & definitions, conditional statements, and calculations to explain what the program is doing.
Your output must match the sample output below as closely as possible; otherwise, the autograding software will not be able to grade your assignment, which may affect your mark.Â
Â
Sample Output:Â
(Note: Make sure each float value is printed to 3 decimal places, and that the last line also prints a new line.)
The below output displays results for a maximum relative intensity of 3.7 and a maximum wave velocity of 22.4 m/s:
Enter max relative intensity & wave velocity: 3.7 22.4
Vibrations have max initial velocity of 39.804 m/s
Blast site has max relative intensity of 6.402
Â
Submission Instructions:
You can either utilize the Mimir IDE found here to create and submit your program, or create your program using CLion and upload it here for grading. Your program file must be named âapsc143assign9.câ in order for your assignment to be graded. Do not include any personal information (student number, name, etc.) in your submission.
To compile and run the program in the Mimir IDE, enter the following command into the terminal:
gcc apsc143assign9.c -lm -o assign9 && ./assign9
Â
Refer to the assignment rubric on OnQ for a detailed breakdown of the grading criteria. Your submission must adhere to the assignment rules as outlined in the submission policy document for this course, which can also be found on OnQ. There is zero tolerance for plagiarism in this course. This autograding software will automatically flag potential cases of plagiarism, which will be reviewed by the instructors.Â
Â
More information on both assignment submissions and the specific definition and repercussions of plagiarism can be found in the âBegin Here (About This Course)â module on OnQ in the âAssignmentsâ and âPlagiarismâ videos, respectively.