Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the function, the program prints rows of stars that show a sine wave. Y

ID: 644284 • Letter: C

Question

Complete the function, the program prints rows of stars that show a sine wave. Your codes in function Q3 should allow users to input two integers: (1) the step value (in degree) and (2) the number of stars as the amplitude value. A sine wave or a cosine wave pattern should then be printed based on the input values. See the section ''Sample sine and cosine wave patterns'' at the end of this question for the sample wave patterns. in the wave pattern, each row represents (he sine (or cosine) value of a particular degree, starting from degree 0 to 360. The difference between the degree values of consecutive rows is equal to the step value input by the user. In each row, the sine (or cosine) value is presented using a horizontal bar of stars that originates from the middle (''I'') to the right (for a positive value) or to the left (for a negative value), followed by the numeric figure in the form like ''sin 40 = 0.6428'' at the right of the wave pattern. Note that the amplitude value input by the user determines the maximum number of stars in the horizontal bar from the middle to the peak position. The following requirements should also be satisfied in this Question 3: 3R1 Use proper prompt messages to ask for user's input of step value and amplitude value. You can assume the users always enter integers when the program asks for these two inputs. 3R2 Your program should only accept an input step value that is within the range of 0 to 360, and is a factor of 360. If an invalid input is received, the program should print a meaningful error message and ask for the input again. 3R3 Your program should only accept an input amplitude value that is within the range of 10 to 30. If an invalid input is received, the program should print a meaningful error message and ask for the input again. 3R4 Make sure the number of stars in each row is correctly calculated, based on the sine (or cosine) value in that row and the amplitude value. Perform necessary round-up on the calculated number of stars (i.e., round-up any decimal that is larger than or equal to 0.5). 3R5 Use stream manipulators appropriately to display the numeric figure at the right of the wave pattern. The sine (or cosine) value should be of 4 decimal places. with sign. and the figures in each row should be left-aligned beside the wave pattern. 3R6 Make sure that your program prints the sine wave pattern 3R7 Appropriate use of nested loop is required in your codes Below is a sample sine wave pattern that your program should print (assume the step value is and the amplitude value is 20):

Explanation / Answer

#include
#include

#define PI 3.14
void main()
{
int stepval,amplival,countstar;

printf("Enter the Step Value (in degrees) between 0 to 360: ");
scanf("%d",&stepval);
printf("Enter the number of stars i.e Amplitude between 10 to 30: ");
scanf("%d",&lival);

if(stepval >=0 && stepval<=360 ||amplival>=10 && amplival<=30)
{
float i;
float sinc,rdeg;

for(i=0;i<=360;i=i+10)
{
rdeg=(i*3.14)/180;
sinc=sin(rdeg);
printf(" %f",sinc);

}
}
else

printf(" Please Enter Step Value Between 0 to 360 & Amplitude Between 10 t0 30");

getch();
}