Answered

Compute the area and circumference of a circle given the radius r if the radius is greater than or equal to 1.0; otherwise, you should compute only the circumference. Repeat the algorithm as much as the user wants.

Answer :

xero099

In this question we shall present the algorithm in pseudocode, whose structure is now summarized:

1) Inputs.

2) Algorithms.

3) Outputs.

Please notice that While-cycles consider the requirement of using the algorithm as many times as user wants.

Name: Area-or-Circunference

CHAR - decide

REAL - radius, circumference, area

Say "Do you want to calculate? [Y] - Yes/[N] - No";

Write decide;

While (decide != 'Y' and decide != 'y' and decide != 'N' and decide != 'n'):

    Say "Invalid option. Do you want to calculate? [Y] - Yes/[N] - No";

    Write decide;

end-While

While (decide = 'Y' or decide = 'y'):

    Say "Please indicate a radius";

     While (radius < 0):

          Say "Radius must be equal or greater than 0. Please indicate a  

                   radius";

          Write radius;

      end-While

      If (radius < 1):

          circumference = 2*3.14*radius;

          Say "The circumference has a value of %circumference length units";

       Else:

          circumference = 2*3.14*radius;

          area = 3.14*radius*radius;

          Say "The circumference has a value of %circumference length units

                   and the area has a value of %area square units";

        end-If

        Say "Do you want to calculate? [Y] - Yes/[N] - No";

        Write decide;

        While (decide != 'Y' and decide != 'y' and decide != 'N' and decide !=

        'n'):

              Say "Invalid option. Do you want to calculate? [Y] - Yes/[N] - No";

              Write decide;

         end-While

end-While

If (decide = 'N' or decide = 'n'):

    Say "Good luck";

end-If

We kindly invite to see this question on algorithms: https://brainly.com/question/17780739

Other Questions