MP0: Triple Crown

Let’s start hacking! MP0 challenges you to complete three small programming tasks. It also introduces you to the development workflow we’ll use throughout the rest of the semester.

MP0 is due Friday 1/26/2018 @ 5PM. To receive full credit, you must submit by this deadline. Late submissions will be subject to the MP late submission policy.

1. Learning Objectives

The purpose of MP0 is to get you started programming in Java. Specifically, it begins to train you to:

  1. initialize and use variables of appropriate types

  2. perform simple calculations using integer arithmetic

  3. use simple loops and conditional statements

  4. translate program descriptions into working code

  5. work with test suites as part of your development process

2. Assignment Structure

MP0 consists of three short programs:

  1. computes the least common multiple of two integers

  2. returns the maximum of last N values of an array of floats

  3. computes a score for a short quiz

2.1. Obtaining MP0

Use this GitHub Classroom invitation link to fork your copy of MP0. Once your repository has been created, import it into IntelliJ following our assignment Git workflow guide.

2.2. Your Goal

All three programs need to be completed. The structure of each is similar:

  1. Each contains a main method that solicits input from the user. You do not need to modify the main methods, but you may want to read them and try to figure out how they work.

  2. User inputs are passed to a separate helper function that you are assigned to write. These functions do the heavy lifting for each program: computing the least common multiple (lcm), returning the maximum (maximumOfLastN), and computing the quiz score (computeScore).

  3. Each program includes a test suite:,, and The test suite does not test the main method. Instead, it directly tests the method that you are assigned to write.

Your goal is to correctly implement the missing methods so that all of the tests pass. Doing so will earn you almost full credit on the assignment—but see the section on style below.

3. How to Approach MP0

Although MP0 may seem daunting at first, do not get discouraged! Focus on identifying what you need to do and understanding the requirements of each function. There is really not a huge amount of code for you to write—our solution adds only several dozen lines, although yours may be slightly longer.

3.1. Understanding What You Need to Do

A core task when approaching any programming assignment or task is to identify what you need to do. For MP0 there are three—and only three—functions that you need to change. Begin by identifying those functions and understanding their requirements. This will go a long way to helping you complete the MP.

3.2. Fixing Initial Errors

Your initial clone of MP0 will receive 0 points. That’s intentional! But once you fix a few small bugs you’re score will improve quickly. In fact, it’s possible to get 40 points for code that doesn’t pass any of the tests—as long as it compiles and runs.

Use IntelliJ to help you here. It can intelligently identify problems with your MP and guide you toward solutions.

3.3. Test-driven Development

We have provided you with testing suites that you can use to perform iterative test-driven development. You should integrate this process into your normal CS 125 Git workflow. Here’s how that works:

  1. Start with one function that you need to write for MP0—say lcm in

  2. Open Run the assignment test suite, which is installed as run configuration "Test MP0". Without changes to, it should fail.

  3. Begin modifying the lcm function. When you think that you have a solution, save you work and re-run the test suite.

  4. If the test suite succeeds, you’re done—congratulations!

  5. If the test suite fails, you may want to run as a Java application and interact with it to determine what is wrong. Perhaps you are calculating the least common multiple correctly when the first value is greater than the second, but not if the second is greater than the first. Interactive testing can help diagnose these kinds of problems.

In general the fewer lines of code you write before running a test, the better. When you are starting out, it is easy to introduce bugs into your code. Bugs are easiest to catch one-by-one, and so the fewer lines of untested code the more likely you are to identify errors in your logic or implementation.

3.4. Getting Help

The course staff is ready and willing to help you every step of the way! Please come to office hours, or post on the forum when you need help. You should also feel free to help each other, as long as you do not violate the academic integrity requirements.

4. Grading

MP0 is worth 100 points total, broken down as follows:

  1. 30 points:

    • 10 points for submitting code that compiles

    • 20 points for passing the test

  2. 30 points:

    • 10 points for submitting code that compiles

    • 20 points for passing the test

  3. 30 points:

    • 10 points for submitting code that compiles

    • 20 points for passing the test

  4. 10 points for no checkstyle violations

4.1. Submitting Your Work

Follow the instructions from the submitting portion of the CS 125 workflow instructions.

4.2. Test Cases

You should carefully review the test cases in,, and The MP0 testing suite follows a common pattern where functions are tested against pre-computed inputs and outputs. So, for example, when testing, we compute the correct answer for a small subset of test cases and use this to determine whether your solution works in all cases.

Automated testing is a hugely important part of modern software development. Just like computers are good at running programs, they are also good at running programs to debug other programs. Independently developing a method and the function that tests it allows the two to support each other. The test may find errors in the method, and, the method may also identify errors in the test.

4.3. Autograding

We have provided you with an autograding script that you can use to estimate your current grade as often as you want. The IntelliJ project a run configuration called "Grade MP0" that will run the autograder for MP0.

Unless you have modified the test cases or autograder configuration files, the autograding output should approximate the score that you will earn when you submit. If you modify our test cases or the autograding configuration, all bets are off. You may also lose points if your solution runs too slowly and exceeds the testing timeouts.

4.4. Style Points

90 points on MP0 are for correctly implementing the required functions. The other 10 points are for style. Writing readable code according to a style guideline is extremely important, and we are going to help you get into this habit right from the start. Every software development company and most active open-source projects maintain style guidelines. Adhering to them will help others understand and integrate your contributions.

We have configured the checkstyle plugin to enforce a variant of the Sun Java coding style. IntelliJ should naturally generate code that meets this standard. So you should not have to fight with IntelliJ too much to avoid checkstyle violations.

However, the checkstyle plugin does require you to add Javadoc comments, and also avoid the use of so-called magic numbers. You may find these requirements a bit annoying at first, but we trust that you will get used to them.

5. Cheating

Please review the CS 125 cheating policies.

All submitted MP source code will be checked by automated plagiarism detection software. Cheaters will receive stiff penalties—the hard-working students in the class that are willing to struggle for their grade demand it.

CS 125 is now CS 124

This site is no longer maintained, may contain incorrect information, and may not function properly.

Created 10/24/2021
Updated 10/24/2021
Commit a44ff35 // History // View
Built 10/24/2021 @ 21:29 EDT