Question: Programming Assignment Start the lab early. If you wait until the last minute to start the lab and find the material difficult, then you risk
Programming Assignment
Start the lab early. If you wait until the last minute to start the lab and find the material difficult, then you risk having to submit the assignment after the due date and incur a late penalty.
This link describes a simple gravity pendulum which consists of a point mass suspended from a string or rod of negligible mass. Write a C program that computes the period T in seconds and frequency f Hz of a simple gravity pendulum given its length cm and the acceleration due to gravity ms The formula for the period is
The formula for the frequency is
The value L is the pendulum length meters and g is the acceleration due to gravity ms Assume that the user will enter positive numbers when prompted for these values. Remember, zero is not a positive number.
Here are tests that you can use to run against your solution in Develop mode. These are the same tests that your solution will be executed against when you submit your work in Submit mode.
Test
run
Enter length cm:
Enter acceleration of gravity ms:
When the pendulum length is meters:
The pendulum period is seconds
The pendulum frequency is Hz
Test
run
Enter length cm:
Enter acceleration of gravity ms:
When the pendulum length is meters:
The pendulum period is seconds
The pendulum frequency is Hz
Test
run
Enter length cm:
Enter acceleration of gravity ms:
When the pendulum length is meters:
The pendulum period is seconds
The pendulum frequency is Hz
Test
run
Enter length cm:
Enter acceleration of gravity ms:
When the pendulum length is meters:
The pendulum period is seconds
The pendulum frequency is Hz
Your solution will be graded based upon program behavior passing tests Your solution will not receive full credit or receives no credit if you fail to follow these restrictions:
Your program must compile and run. Otherwise it will receive a zero.
Add your solution to the provided code template.
Use descriptive variable names. Avoid too short variable names, especially single letter variable names.
DO NOT start a variable name with a capital letter.
DO NOT use explicit type casting. Instead use coercion see lecture notes
DO NOT unnecessarily use parenthesis in an expression, eg an equation or formula. Parenthesis should only be used for grouping portions of an expression to change operator precedence order. For example, parenthesis are unnecessary in the expression a b c Instead use a b c Parenthesis are necessary in the expression a b c
Your program must be readable including indenting, spaces, and avoid lines that are too long. Use the the sample programs in the lecture notes as a guide.
Comment your program. Read the document at the "Lecture" link on Carmen under ModulesCommenting Your Program Commenting your program. DO NOT comment every line.
Only use C statements presented in the course. I.e statements and notation presented in the lecture notes and assigned readings.
Study the lecture notes Powerpoint slides and prerecorded lectures and assigned readings BEFORE starting this assignment.
To receive full credit, only use C statements presented in the lecture notes and assigned readings. Your solution will be graded based on passing test cases, formatting, and good choice of variable names. Write your solution in the provided code template.
Important!: Write your code incrementally. This means implement your solution one portion at a time where you compile, run, and test the code portion before moving on to the next portion. Use the provided test cases to help you arrive at your final solution.
TASK : Study the lecture notes Powerpoint slides and prerecorded lectures and assigned readings before you start.
TASK : Replace with your name, creation date, and a description of the program synopsis
NOTE: DO NOT delete nor change the code already given to you in the code template, except for the comment INSERT YOUR CODE HERE You will insert your solution by replacing INSERT YOUR CODE HERE
TASK : Write C code to prompt and read from the user for the pendulum length and acceleration due to gravity. Test your code until it works before continuing to the next task.
TASK : Write C code to compute the period time T and frequency and display these computed value to the output screen.
Be sure that there is a comment documenting each variable see the document on Carmen under Modules on how to comment your code
Be sure that your code is properly indented, readable, and use good descriptive names. Using L or g are improper variable names. Do not start a variable name with a capital letter.
Test your solution.
Program Submission
Important: Any program which
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
