Question

6) Plot a star that prompts the user to enter how many points the star has. Only worry about odd numbered points. Indicate to

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

n=input('Enter the number of points.Only odd numbers are allowed');

Rotangle= 0;% Angle of rotation to rotate the star at requirement.
centx = 3;%Position of center of the star with respect to x-axis.
%You can change at your requirement

centy= 7;%Position of center of the star with respect to y-axis

theta = Rotangle + (0 : (n-1)/n*pi : (n-1)*pi);
% angles that the arm tips are located at
amplitude = 3;%distance from the center of star to the arm tip.

%x and y coordinates of the arm tips.
x = amplitude .* cos(theta) + centx;
y = amplitude .* sin(theta) + centy;

plot(x, y, 'r', 'LineWidth', 2);grid on; axis square;

code snippet:

  • = 1 n=input(Enter the number of points. Only odd numbers are allowed); 2 3 Rotangle= 0;% Angle of rotation to rotate the st

Results:

Enter the number of points.Only odd numbers are allowed 7 10 8 6 >> gam Enter the number of points. Only odd numbers are allo10 9 8 7 6 5 4 0 1 3 4 5 610 9 8 7 A 6 5 4 0 2 3 4 5 6

Add a comment
Know the answer?
Add Answer to:
6) Plot a star that prompts the user to enter how many points the star has....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How do I solve using Matlab? Plot a star that prompts the user to enter how...

    How do I solve using Matlab? Plot a star that prompts the user to enter how many points the star has. Only worry about odd numbered points. Indicate to the user only odd numbers can be entered. Change the star line color to red.

  • C++ Write a program that prompts the user to enter integers or a sentinel to stop....

    C++ Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...

  • In C++ Prompts the user to enter 5 numbers. Once the user has entered the 5...

    In C++ Prompts the user to enter 5 numbers. Once the user has entered the 5 numbers, the program should calculate and display the average of the 5 numbers.and The program prompts the user for one number at a time, without using for

  • In C++ Prompts the user to enter 5 numbers. Once the user has entered the 5...

    In C++ Prompts the user to enter 5 numbers. Once the user has entered the 5 numbers, the program should calculate and display the average of the 5 numbers.and no for(;;) while(1) while(true) do{//code}while(1); without cin The program prompts the user for one number at a time

  • Write a program which prompts the user to enter a number of rows, and prints a...

    Write a program which prompts the user to enter a number of rows, and prints a hollow square star pattern with 2 diagonals. Note: you can assume that the integer will always be > 1 and will be an odd number. For example: Input Result 5 Enter number of rows: 5 ***** ** ** * * * ** ** ***** 9 Enter number of rows: 9 ** ** ** * * * * * * * * * * **...

  • please solve using python thank you! Write a program which prompts the user to enter a...

    please solve using python thank you! Write a program which prompts the user to enter a number of rows, and prints a hollow square star pattern with 2 diagonals. Note: you can assume that the integer will always be > 1 and will be an odd number. For example: Input Result 5 Enter number of rows: 5 ***** ** ** * * * ** ** ***** 9 Enter number of rows: 9 ** ** ** * * * * *...

  • Write a complete java program that prompts the user for their name and two numbers. The...

    Write a complete java program that prompts the user for their name and two numbers. The correct java methods and parameters must be passed to find the length of the name entered and return “TRUE” if the sum of numbers is even, or FALSE if the sum of numbers is odd: Notes included in the program Sample Program Please enter a name and I will tell you the length of the name entered John Then length of the name John...

  • C++ Problem #1 Write a program that prompts user to enter an integer up to 1000...

    C++ Problem #1 Write a program that prompts user to enter an integer up to 1000 and displays back a message about the number of digits in this number and if number is odd or even. For example, if user enters 93 message back should be "93 has 2 digits and is odd".

  • (java) Write a While loop that prompts the user for only even numbers. Keep prompting the...

    (java) Write a While loop that prompts the user for only even numbers. Keep prompting the user to enter even numbers until the user enters an odd number. After the loop ends, print the sum of the numbers. Do not include that last odd number. You should not store the numbers in an array, just keep track of the sum. Make sure to use a break statement in your code. You may assume that a java.util.Scanner object named input has...

  • Write a program that prompts the user for positive integers, only stopping when a negative integer...

    Write a program that prompts the user for positive integers, only stopping when a negative integer or zero is given. The program should then print out how many of the positive integers were odd. Example: Enter a positive integer (0 or negative to stop): 9 Enter a positive integer (0 or negative to stop): 4 Enter a positive integer (0 or negative to stop): 7 Enter a positive integer (0 or negative to stop): -3 You entered 2 odd integers....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT