MP1: Triple Crown

Let’s start coding! MP1 challenges you to complete three small programming tasks. It will also introduce you to the testing environment we’ll use throughout the rest of the semester.

MP1 is due Friday, September 22nd, 2017 @ 5PM. To receive full credit, you must submit by this deadline.

1. Learning Objectives

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

  1. translate program descriptions into working code

  2. find and fix bugs in existing code

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

  4. format text output using appropriate Java classes

  5. initialize and use variables of appropriate types

  6. perform simple calculations using integer arithmetic

  7. use simple loops and conditional statements

2. Assignment Structure

MP1 consists of three short programs:

  1. computes the factorial of a given number

  2. returns three scores in sorted order

  3. gives a short quiz about CS@Illinois and displays a score

2.1. Obtaining MP1

You will find the MP1 project located in a new MP1 directory in your Subversion repository. To import it into your workspace, perform the following steps in Eclipse:

  1. Open the Eclipse project import dialog: "File → Import"

  2. Choose to import a Subversion project: "SVN → Project from SVN"

  3. If you have set up your Subversion repository previously following our instructions, you should have an option to use an existing repository location. Select your CS 125 Subversion repository.

  4. On the next screen hit "Browse". You should see a "MP1" directory inside your Subversion folder. Select it and click "OK".

  5. Your Subversion URL for MP1 should look something like this: So for example, my MP1 is located at

  6. Click "Finish" and then ensure that "Check out as a project with the name specified" is selected.

  7. Click "Finish" again.

  8. You should have a copy of MP1!

2.1.1. Recovering in case of accidental deletion

If for some reason you delete you original copy, there are ways to get it back using Subversion 1. Make sure you import it as an existing Eclipse project, otherwise other things are unlikely to work correctly.

At that point you’ll want to follow our instructions on adding projects to your Subversion repository. Note that your project must be in a subdirectory named MP1 in your Subversion repository! Otherwise we will not find it when you look for it to grade.

2.2. Your Goal

All programs and incomplete and need work. The structure of each program 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 should understand 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 factorial (factorial), returning sorted scores (winner), 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 MP1

Although MP1 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 36 lines, although yours may be slightly larger.

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 MP1 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. Test-driven Development

We have provided you with testing suites that you can use to perform iterative test-driven development. Here’s how that works:

  1. Start with one function that you need to write for MP1—say factorial in

  2. Open and Run the test suite. Without changes to, it should fail.

  3. Begin modifying the factorial 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 factorial of 2 correctly, but the factorial of 3 incorrectly? 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.3. 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

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

  1. 30 points:

    • 10 points for submitting code that compiles

    • 10 points each for two non-trivial test cases

  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. Test Cases

You should carefully review the test cases in,, and The MP1 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.2. Autograding

We have provided you with an autograding script that you can use to estimate your current grade as often as you want. The Eclipse project contains a launcher that will run the autograder for MP1.

Unless you have modified the test cases or autograder configuration files, the autograding output should equal the score that you will earn when you submit. If you modify our test cases or the autograding configuration, all bets are off.

4.3. Style Points

90 points on MP1 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. We have also configured Eclipse to generate code that meets this standard. So you should not have to fight with Eclipse 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. Submitting Your Work

Overall you should refer to our instructions for using Subversion. Commit early and often! You only earn credit for the version of your code that is committed to your repository, so ensure that we have your best submission before the deadline.

5.1. Academic Integrity

Learning to program requires practice. If you submit code that is not your own work, you are not getting the practice that you need to improve.

All work submitted for MP1 must be your own. Cheating in CS 125 may result in your removal from the CS program, or from the University of Illinois. We have many bright, honest students that want to learn computer science. We don’t need to waste time and energy on cheaters that don’t want to learn.

Specifically, the following activities constitute cheating and will be dealt with according to relevant departmental and university policies. You may not:

  1. Turn in work that was completed by anyone other than yourself.

  2. Copy or paste code that you did not write from any source.

  3. Examine another classmates solution, reproduce it, and submit it as your own work.

We reserve the right to run cheating detection software on all submitted student work. These programs are extremely accurate, and any evidence of cheating that they uncover will initiate academic integrity violation proceedings.

5.1.1. A simple rule of thumb about collaboration

A general rule of thumb is that exchanging or soliciting ideas about how to solve the MP is not cheating, but exchanging code is cheating. Feel free to discuss your solutions with other students as long as you do not provide them or allow them to view your source code. If you are talking in English 2, that’s fine. If you are talking or exchanging computer code, that’s cheating.

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