60 likes | 71 Views
This article discusses the process of writing generic algorithms for drawing solid and outline rectangles, along with error checking for dimensions. It also explains the concept of finding the floor of a real number X. The article includes information on upcoming assignments, exams, and additional topics to be covered.
E N D
More Algorithms Topics • More Algorithms
Writing Algorithms • Given a problem statement, we are going to write the corresponding generic algorithm for the solution in terms of input and output. • We will use the following procedure: • Define variables using comments. • Get input from the user. • Perform tasks or calculations in order to get the correct solution. • Output results to the user.
Drawing a Solid Rectangle Problem: Write an interactive program that will draw a solid rectangle of asterisks (*) in terms of width and length. The program must also display the dimensions of the rectangle. Error checking must be done to be sure that the dimensions are greater than or equal to one.
Drawing an Outline Rectangle Problem: Write an interactive program that will draw an outline rectangle of asterisks (*) in terms of width and length. The program must also display the dimensions of the rectangle. Error checking must be done to be sure that the dimensions are greater than or equal to two.
Floor of X • Given a real number X, floor of X, denoted X , is the largest integer that is less than or equal to X. • For example, 3.9 = 3 7.0 = 7 -2.8 = -3
Assignment and Next • Exam 1 on Wednesday Oct. 2. • Homework 3 due on Monday, Sept. 30, 2:00 PM. • Visit out class at least once a day: http://www.cs.umbc.edu/courses/undergraduate/104/fall02/chen/ Next: • Go over Homework 2. • More algorithms. • Review for the Exam 1.