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 (m/s2). 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 (m/s2). 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 1
> run
Enter length (cm): 100
Enter acceleration of gravity (m/s^2): 9.8
When the pendulum length is 1 meter(s):
The pendulum period is 2.00709 second(s).
The pendulum frequency is 0.498234 Hz.
Test 2
> run
Enter length (cm): 5015.25
Enter acceleration of gravity (m/s^2): 9.8
When the pendulum length is 50.1525 meter(s):
The pendulum period is 14.2139 second(s).
The pendulum frequency is 0.0703537 Hz.
Test 3
> run
Enter length (cm): 100
Enter acceleration of gravity (m/s^2): 3.71
When the pendulum length is 1 meter(s):
The pendulum period is 3.26207 second(s).
The pendulum frequency is 0.306554 Hz.
Test 4
> run
Enter length (cm): 7035.76
Enter acceleration of gravity (m/s^2): 8.87
When the pendulum length is 70.3576 meter(s):
The pendulum period is 17.6959 second(s).
The pendulum frequency is 0.0565101 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, e.g. 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)/3.
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 Modules->Commenting 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 pre-recorded 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 1: Study the lecture notes (Powerpoint slides and pre-recorded lectures) and assigned readings before you start.
TASK 2: 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 3: 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 4: 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!