Studio : Getting Started

Studio Sessions Overview

Studio activities should not be started before class! Come to the session and work on the activity with other students!

Studios are a chance to work with other students to learn course material by actively trying to solve problems.

  1. Form a group of 2-3 students and find a TA or instructor to work with (TAs/instructors may be working with 2-3 groups at a time)
  2. Credit is based on good faith participation:
    • The goal is to explore the module’s course topics by working on the given activity. Credit is not based on any specific solution nor do you even need to complete the activity.
    • Credit is given based on your active participation in the activity. If you arrive late (more than 15 minutes) or don’t actively contribute to the work, you will not be given credit.
    • Be a constructive member of group:
      • Prepare in advance by completing the prep materials.
      • Ask questions and discuss topics. Try to make sure your entire group completely understands the topics being used.
      • Be polite and respectful of your group members!
      • Each member of your team is responsible for ensuring that all members completely understand your work and the topics being used.

Academic Integrity Agreement

Today, course staff will hand out an Academic Integrity Agreement. Each person should review and complete the first page, which requires printing your name and student ID number, initialing next to each item, and signing.

Your group should review and discuss the Examples of what you can and can’t do. When everyone is clear about what is allowed, have a TA/instructor complete the back of the form and proceed.

Studio Setup and Procedure

  • All but one member of your group should have this web page open so you can follow along and see the instructions as you work.
  • Plan to have one computer at which your team does its work (usually using Eclipse). Initially, one of you will be in charge of typing at that computer.
  • Throughout the studio you should trade who is in charge of the keyboard.


  1. Have one person in your group create a new team by clicking here and going to the OR Create a new team box at the bottom of the page.
    1. The team name should include the last names of all your group members. For example, if Xia and Smith are working together, the team name should be something like “XiaSmith”.
  2. After the team is created, all other members of your team should click on the same link and follow the instructions to join the team.
    1. Be careful to join the right team! You won’t be able to change teams yourself and will have to contact instructors if there’s a problem.
    2. Be sure everyone else joins the team! If grades don’t get entered correctly we will use the team to help verify credit for a particular studio.
  3. Finally, one person should import the studio repository into Eclipse, as described in Assignment 0’s Add the assignment to Eclipse
    • All team members will have access to the work pushed to GitHub. Be sure to Commit and Push at the end of the day so everyone can refer back to the work later as needed.

Studio 1: Activity

  • You will complete a series of simple Java programs, and run each program to ensure it performs its task correctly.
  • The files for this program are in the src/studio1 package of the repository you loaded.
  • To run a program just open the file in a tab and click on the green “Play” button on the menu. The program in the active/open tab will run.

Some of the following exercises are adapted from Princeton University's COS126 course, based on our text by Sedgewick and Wayne.

For each of the following exercises, find the file in your studio repository and complete it to do the assigned task.


Say hello to the name supplied as input to this program.

Sample output: Hi Bill. How are you? (assuming Bill was supplied as input) Feel free to end the output with punctuation that indicates the level of enthusiasm associated with your greeting.


Switch who is “entering code”; Everyone should have equal time entering code

Expand your hospitality to the four names supplied to this program.

Sample output: Greetings Cormen, Leiserson, Rivest, and Stein. Be sure to put in proper punctuation to separate the names.


Switch who is “entering code”; Everyone should have equal time entering code

Define a boolean variable isOrdered whose value is true if the three values are either in strictly ascending order (x < y < z) or in strictly descending order (x > y > z), and false otherwise. Print out the variable isOrdered using System.out.println(isOrdered).

Some of you may already know some Java. We have not yet covered the if statement. You must use what has been taught so far (simple expressions and assignment) to accomplish this task.


Switch who is “entering code”; Everyone should have equal time entering code

Complete this code so that it prints the average of its two integer inputs.

Sample output: Average of 5 and 6 is 5.5.

Note that the output is specified as a double, because the average of two integers is not necessarily an integer.

OK, for this one, you are on your own. We are not giving you code for this, but will instruct you how to create your own Java class file from scratch:

  1. Right- (control-) click on the studio1 package, select New > Class.
  2. Type the name Average in the Name: field
  3. Click the box that says public static void main(String[] args)
  4. Click the Finish button, which will create the new file
  5. At the top of the main method, you need to insert the ArgsProcessor code to accept two integers: n1 and n2.

    Refer to other studio code to see how this is done.
    Depending on how you add the code referring to the ArgsProcessor, Eclipse may flag your code with an error. If so, you can get Eclipse to solve its own problem by mousing over the error (red underline), and using the first suggestion that pops up, namely to import ArgsProcessor. Try to use meaningful messages to prompt for values.

    A not so nice prompt:

    int n1 = ap.nextInt("Yo, sup?");

    And a nice prompt:

    int n1 = ap.nextInt("The first of two integers to be averaged?");

    Run your program and makes sure it prompts you correctly for its values and ask a TA to check your work at this point.

  6. Finish the class so it prints out the appropriate message.

Creative Exercise

Switch who is “entering code”; Everyone should have equal time entering code

Ice Cream

As a group, brainstorm the best data type to represent the following situations:

Often, there is no right or wrong answer. Be prepared to defend your choices.

  • The number of times you have been to Ted Drewes
  • Whether you like Ted Drewes’ vanilla frozen custard or not
  • The number of people you can take in your car
  • The price of a regular size concrete vanilla frozen custard
  • The name of your favorite flavor from Ted Drewes
  • The address of the Ted Drewes
  • The probability that you will see a friend at Ted Drewes

Demo (get credit for your) your work:

Commit and Push your work. Be sure that any file you worked on is updated on GitHub.

To get participation credit for your work talk to the TA you’ve been working with and complete the demo/review process. Be prepared to show them the work that you have done and answer their questions about it!