Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write down C++ code E.2 Printing a Full-wave Reciied Sine Curve Requirements Your program will print a vertical, full-wave rectified sine curve on the

image text in transcribedimage text in transcribed

Please write down C++ code

E.2 Printing a Full-wave Reciied Sine Curve Requirements Your program will print a vertical, full-wave rectified sine curve on the console using *" characters. You must not include the library Specifications The program will ask the user to enter a real number value indicating how many sine wave cycles they wish to print to the screen. The reason for allowing a decimal number to be entered is so that a partial cycle can be printed Remember that a single cycle of a sine wave can be shown as 1. And a single cycle of a full-wave rectified sine wave can be shown as: For simplicity, we are going to print this wave vertically on the console Use a for loop, or set of nested for loops to print an appropriate number of "*" characters to the console to represent the rectified sine wave as shown in the sample output section below. For more details on printing characters to the console with for loops, see lecture unit 4, slides 99-100 Hint: To find how many characters should be printed on each console line, first calculate the sine value for an increasing number of degrees. You could use a loop structure with the number of degrees being incremented on each iteration up to the number of desired degrees (number of cycles multiplied by 360 degrees/cycle). Inside the loop, you should convert this value in degrees to radians using the formula 2. radians = degrees * 180.0 Once the sine of this converted number is found as a real number, you can multiply this by a fixed integer (Ex. 20) representing the maximum number ofs to be printed to the console 3. Since using the cmath library is not allowed for this question, you will have to write your own computation of a sine wave. The formula listed for approximating this computation is listed below where x is an input in radians. You must choose a value for N, which represents the number of iterations that the approximation will run for. The larger this value, the more accurate your approximation will be but a large value will slow down computation significantly. Experiment with different values of N and check the computation accuracy. Note that an exponent indicates how many times a variable is multiplied by itself. Use an additional loop to make this calculation (-1)"x2n+1 n=o (2n+ 1)! 7 sinx = x--+ + ~ 3! 5! 7! 4. No marks will be awarded for the question if the 'cmath' library is included! Page 5 of 12 ES1036 Lab 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions