EECS 183 Labs

EECS 183 Lab 5: Loops

Lab due on your scheduled lab day (Sept 24 - 30)

Lab accepted for full credit until Tuesday, October 1, 2024, 11:59 pm Eastern

In this lab, you are writing code and solving practice exam questions to master the use of loops.

By completing this lab assignment, you will learn:

You should complete this lab in small groups of about four students. For all labs in EECS 183, to receive a grade, every student must individually submit the Lab assignment.

Starter Files

You can download the starter files using this link.

The IDE setup tutorials for Visual Studio and XCode include a video about how to set up a project using the starter files. You can access the tutorials here:

After downloading and unzipping, you will find the following files in the starter-files folder:

IMPORTANT: For this lab, you must include all three files in a single project in Xcode or Visual Studio.

Lab Assignment

Tasks to Complete

  1. Start a new project with your IDE using the starter files according.
  2. Stub all of the functions in loops.cpp - see Function Stubs for details.
  3. Write your test cases in test.cpp to test the three print functions you will implement in loops.cpp.
  4. Write the implementations for the functions in loops.cpp:
    • printRectangle()
    • printRight()
    • printRightJustified()
    • printIsosceles()
  5. Test your functions using the test cases you have written.
  6. Submit your loops.cpp and test.cpp to the autograder.

Multiple Files

Function Stubs

A function stub is a temporary substitute for a function that needs to be implemented. In all projects and labs so far in EECS 183, we have provided all of the function stubs for you. Starting with this lab, you will need to create function stubs for all of the functions you will implement.

void printRectangle(int rows, int cols) {
    // TODO - implement
    
    return;
}

Testing

Bugs To Expose

There are a total of 4 unique bugs to find in our implementations of loops.h functions. Your tests will need to expose all of the bugs to receive full points for the lab. The autograder will tell you the names of the bugs that you have exposed, from the following set:

printRectangle()

IMPORTANT: Differences in whitespace do matter for this function.

/**
 * Requires: rows must be > 0,
 *           cols must be > 0
 * Effects:  prints a rectangle of *'s
 *           prints an endl at the end of each row
 *
 */
void printRectangle(int rows, int cols);
printRectangle(3,2);
cout << endl;                  <== prints a blank line
printRectangle(1,3);
cout << endl;                  <== prints a blank line
**
**
**
           <== blank line
***
           <== blank line

printRight()

IMPORTANT: Differences in whitespace do matter for this function.

/**
 * Requires: n must be > 0
 * Modifies: nothing
 * Effects:  prints a right triangle
 *           prints an endl at the end of each row
 *
 */
void printRight(int n);
printRight(3);
*
**
***

printRightJustified()

IMPORTANT: Differences in whitespace do matter for this function.

/**
 * Requires: n must be > 0
 * Modifies: nothing
 * Effects:  prints a right justified triangle
 *           prints an endl at the end of each row
 *
 */
void printRightJustified(int n);
printRightJustified(3);
  *
 **
***

printIsosceles()

IMPORTANT: Differences in whitespace do matter for this function.

/**
 * Requires: n must be > 0
 * Modifies: nothing
 * Effects:  prints an isosceles triangle (pointing up)
 *           where parameter n is the height
 *           prints an endl at the end of each row
 *
 **/
void printIsosceles(int n);
printIsosceles(3);
  *
 ***
*****

How to Submit

IMPORTANT: For all labs in EECS 183, to receive a grade, every student must individually submit the Lab Submission. Late submissions for Labs will not be accepted for credit. For this lab, you will receive ten submissions per day with feedback.