Question

Write a Matlab program that displays on the screen checkerboard patterns comprising of two alternating_colors to be selected by the user. Your program MUST use as the checkerboard unit pattern a SQUARE INSCRIBED INSIDE A CIRCLE with unit pattern width and checkerboard dimension also to be inputted by the user. Your program MUST perform the FOLLOWING TASKS 1. Prompt the user to enter the following variables: (a) the width of each square (the width MUST be positive), where each square will be inscribed inside the circle. (b) the dimension of the checkerboard (the dimension MUST be an integer and greater than 1) to be displayed on the screen (c) Prompt the user to enter two different colors from the following table: k black red ellow green blue ue magenta white cyan (d) You MUST verify (a) if the width entered is positive, (b) if the dimension is integer and greater than 1, and (c) if the colors selected are within the ones listed in the table above, and allow the user to re-enter the width, dimension, and colors WITHOUT THE NEED to rerun the program 2. Your program MUST allow the user to START OVER as often he/she wishes, WITHOUT THE NEED to rerun the program Hint use the command fill(x.y,color) to fill each square with the desired color Ex : A checkerboard with square width=2 , dimension-3 , and black and white colors.

please solve the Program USING MATLAB. do not do #2. write in details for the command lines.

Make sure the program runs and also completely does what it askes please

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

width = input('Enter width: ');
while width < 0
    width = input('Width can not be negative. Please try again: ');
end

dimension = input('Enter dimension: ');
while true
    if dimension < 1
        dimension = input('Dimenstion can not be less than 1. Try again: ');
    else
        break;
    end
end

color1 = input('Enter color1: ', 's');
while true
    if length(strfind('rygkbmwc', color1)) == 0
        color1 = input('Invalid. Try again: ', 's');
    else
        break;
    end
end

color2 = input('Enter color2: ', 's');
while true
    if length(strfind('rygkbmwc', color2)) == 0
        color2 = input('Invalid. Try again: ', 's');
    else
        break;
    end
end

printf('Width = %d\n', width)
printf('Dimenstion: %d\n', dimension)
printf('Color1: %s\n', color1)
printf('Color2: %s\n', color2)

Add a comment
Know the answer?
Add Answer to:
please solve the Program USING MATLAB. do not do #2. write in details for the command...
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
  • Write a program that takes a positive integer n as input from the user and displays...

    Write a program that takes a positive integer n as input from the user and displays an n by n checkerboard. (Hint: your main method could do user input then call the constructor for your GUI with n as the argument.) For example, when n = 5, there are 25 alternating white and black squares inside a square boarder. The lower right corner of the overall pattern must be white. Make sure that adjacent squares are different colors regardless of...

  • How do I solve using Matlab? Use MATLAB to create a pattern such as the one...

    How do I solve using Matlab? Use MATLAB to create a pattern such as the one below in the command window. Prompt the user to enter the max number of columns and number of intervals ran. In the left figure, the user selected 10 max columns and one interval. In the right figure, the user selected 5 max columns and two intervals. The program should run for n max columns and n number of intervals. **** ***** ***** *****

  • Using MATLAB program to solve the following question please: Write a script called echostring that will...

    Using MATLAB program to solve the following question please: Write a script called echostring that will prompt the user for a string, and will echo print the string in quotes (with an extra little surprise at the end): >> echostring Enter your string: I like nap Your string was: ‘I like nap – in MATLAB class’

  • #6 Write a Matlab program that finds numerically all the roots (or the zeros) of the...

    #6 Write a Matlab program that finds numerically all the roots (or the zeros) of the algebraic equation below in the interval 1.0 <=x<=3.0: sqrt(log(x^2+1))=x^2*sin(e^x)+2 Part a) Prompt the user to enter a positive integer number n, defined the range 2<=n<=15, and then verify if the number entered lies within the specifications. Your program must allow the user to reenter the number without the need to rerun the program. Part b) Create a user-defined function for the bisection method(see details...

  • Using MATLAB (a) Write a computer program capable of zooming and shrinking an image by pixel...

    Using MATLAB (a) Write a computer program capable of zooming and shrinking an image by pixel replication. Assume that the desired zoom/shrink factors are integers. - Ask a user to choose a picture - Ask the user to enter the factor - The factor must be an integer - Use if- statement it the user wants to zoom or shrink. - Make the user re-enter if he/ she doesn't enter the factor number as an integer.

  • Write a Java program that uses the Monte Carlo method to estimate the value of PI....

    Write a Java program that uses the Monte Carlo method to estimate the value of PI. This method uses the unit circle inscribed in a square with sides of length 2 and random numbers to perform the estimation. The estimation works as follows: • Two random numbers are generated during each iteration of a loop. • The random numbers are each in the range of -1 to 1. One random number is the x-coordinate and the other is the y-coordinate....

  • 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 ** ** ** * * * * *...

  • Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu:...

    Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu: Enter Circle Enter Rectangle Remove Shape Draw Shapes Exit Circles – User inputs position, radius, and color. The position is the CENTER of the circle Rectangles – User inputs position, height, width, color. The position is the lower left-hand corner Colors – Allow red, yellow, blue, and green only Remove – Show the number of items in the list and let the user enter...

  • Please show in MATLAB code using if and else statements if necessary Write a program in a script ...

    Please show in MATLAB code using if and else statements if necessary Write a program in a script file that converts a quantity of energy given in units of either J (Joules), Btu, or (ft-lb) to the equivalent quantity in different units specified by the user. The program asks the user to enter the quantity of energy, its current units, and the new desired units. The output is the quantity of power in the new units using the fprintf command....

  • Q3)  A day has 86,400 secs (24*60*60). Given a number in the range 1 to 86,400, output...

    Q3)  A day has 86,400 secs (24*60*60). Given a number in the range 1 to 86,400, output the current time as hours, minutes, and seconds with a 24-hour clock. For example:70,000 sec is 19 hours, 26 minutes, and 40 seconds. Q4) Consider a triangle with sides of length 3, 7, and 9. The law of cosines states that given three sides of a triangle (a, b, and c) and the angle C between sides a and b: c square = a...

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