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 T = 2n, f = 2n V L acceleration due to gravity (m/s²). The formula for the period is value L is the pendulum length (meters) and g is the acceleration due to gravity (m/s?). Assume that the user will enter positive numbers when prompted for these values. Remember, zero is not a positive number. and the formula for the frequency is The 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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I need code on C++ for the following. 

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
T = 27L
1
f =
2n VL
acceleration due to gravity (m/s2). The formula for the period is
value L is the pendulum length (meters) and g is the acceleration due to gravity (m/s?). Assume that the user will enter positive numbers
and the formula for the frequency is
The
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.
Transcribed Image Text: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 T = 27L 1 f = 2n VL acceleration due to gravity (m/s2). The formula for the period is value L is the pendulum length (meters) and g is the acceleration due to gravity (m/s?). Assume that the user will enter positive numbers and the formula for the frequency is The 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.
• 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 pendulum length 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.
Transcribed Image Text:• 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 pendulum length 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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY