APCS Unit 2: Beginning Java

How to write your first Java programs


Welcome to the beginning of Java here in AP Computer Science!  Our study of computer science will start in this unit at the very beginning of what goes into a Java program.  In order for a program to be able to be compiled (built) by the computer and run (used) by a human user, it needs some basic components to help define the program, classes, and main method that will tell the program what to do. This unit will introduce those most basic components and give you some practice making basic programs.

As we work through this unit, we’ll get to work with 3 main ideas:

  • How to make a basic program print text on the screen
  • How to make a basic program get input from a user’s keyboard
  • How to do math in Java and create a basic calculator

When you’re done, you’ll have your own working calculator!


(20 pts)  About 3 days

The beginning of learning any programming language is usually the creation of a simple program that prints the words “Hello world!” on the screen.  Here in AP Computer Science, we’ll start our learning of Java with exactly this program along with a complete introduction to our IDE of choice: BlueJ


(30 pts)  About 3 days

With the basics of a Java program and BlueJ under our belts, we turn our attention to how to use a scanner to get input from the user of our program.  With this, we can understand words and numbers that the user is trying to tell us, and then we can do different things with them.  Here we’ll practice taking user input for different purposes.


(30 pts)  About 2 days

To wrap up our unit, you’ll use the different user interfacing and printing techniques we’ve discussed to create a simple calculator.  To do this, we’ll even add in our first – and most simple – control structure: the if statement.  When you’re done with your final unit project, you’ll have a custom calculator that can do some of your homework for you!

PART 1: "Hello World!"

Introduction to BlueJ and "Hello World"

BlueJ Reference

 Download BlueJ at Home!

 NOTE:  BlueJ is already installed on our lab computers.  Please do not try to install a second copy!

Here in our second unit, we get to start learning the basics of ‘real’ programming in a language called Java.  Java is one of many high-level programming languages that include Java, C++, Python, Arduino, Ruby, Swift, and many, many more.  Our entire year will be spent programming in Java and by the end of the year you’ll be able to make impressive and useful programs all on your own from scratch, and you’ll also have a deep understanding of the fundamental ideas that help make all programming languages possible.  First, we’ll start with the basics.


 Use your Engineering Notebook to take a full page of notes on BlueJ and basic Java programming thoughts.  Watch all three videos and write down important things you see.

 Complete your first program:  “Hello World!”

 Complete Java Tasks 1-5: Beginning Printing

 Have Mr. Benshoof confirm your working wiring when its all soldered and ready to go!

What is Java?

Introduction to BlueJ

Print Statements in Java

What’s Due In Beginning Java Part 1: “Hello World”

  • Java Notes
  • “Hello World!”
  • 5 Printing Tasks
  • Benshoof’s Check-Off

Here’s what’s due in Part 1: Hello World!

  1.  Take a full page of notes on the three introductory Java videos
  2. Complete the first program “Hello World!”
  3. Complete the 5 Beginning Printing Java Tasks
  4.  Have Benshoof check-off your working programs

PART 2: User Input

Talking to the keyboard to get user input

Scanner Method Reference

Now that we know the basics of creating a simple program and printing text to the screen, it’s time to start including the user in our programs!  Users are people that sit at the computer and interact with what’s going on on the screen.  The first – and most important – source of user input is the keyboard, and here we’ll use a Scanner to talk to the keyboard.  The Scanner is an object (much like a Jeroo) that can talk to the keyboard and see what numbers or words the user has typed.  In the next part, we’ll make some Scanners and use them to get user input.

The Scanner Class

Another Perspective on Scanners

If & If-Else Statements

What’s Due In Beginning Java Part 2: User Input

  • Scanner & If Notes
  • 6 Input Tasks
  • Benshoof’s Check-Off

Here’s what’s due in Part 1: Wiring

  1.  Take a good page of notes on If statements and Scanners
  2. Complete the 6 Tasks about user input using Scanners
  3.  Have Benshoof check-off your Input Tasks

PART 3: Calculator

Using what you know about Java to make a simple calculator

Math Class Reference

Now that we know how to get information from the user, and how to print numbers and results back to the user, it’s time to put that information to work!  Here, you’ll think about some other math course you’re in and create a calculator that can solve 3 equations for you. To do this, you’ll need to make a program that first asks the user which equation they want to solve.  Based on their response, you’ll need to ask for specific variables.  Then, your program will need to plug those values into the equation using various Math class operations.

The Math class is a group of methods that let us do bigger math operations.  Things like square roots (Math.sqrt), exponents (Math.pow), and pi (Math.PI) are just a few of the methods and variable available in the Math class.  You’ll need to find the best way to perform your calculations, and then double check that your calculator is working correctly.

Math Class Overview

Math Class Details

What’s Due In Beginning Java Part 3: Calculator

  • Math in Java Notes
  • Calculator Program
  • Log 2: Java
  • Benshoof’s Check-Off

Here’s what’s due in Part 3: Calculator

  1. Take a page of notes on the Java Math class
  2.  Create your complete Java Calculator program using Math class methods
  3.  Complete Log 2: Beginning Java
  4.  Have Benshoof check-off your finished, working calculator!

Double Check: Unit Expectations

Check what you need to have completed by the unit deadline

The purpose of this unit is to use the Engineering Design Process to wire, design, and build a working Bug Bot.  You should have had the chance to do some soldering, design your own Bug Bot, and use the tools in our makerspace to build your Bug Bot.  If you were really on-task and working hard, you should have also had time to decorate your Bug Bot to make it look super cool.  By the unit deadline, you should have completed and be able to submit the following items:

Engineering Notebook:

 (Part 1) Definition of problem, criteria, constraints, and Bug Bot Overview notes

 (Part 1) Wiring diagram, soldering notes, and wiring reflection

 (Part 2) Bug Bot Design brainstorm, notes, and careful drawing

 (Part 3) Final drawing/picture, half-page written reflection on Bug Bots

Building & Making:

 (Part 1) Wiring should work, soldering should be clean and complete

 (Part 2) Bug Bot design should be carefully drawn out including labels and diagrams

 (Part 3) The Bug Bot should be assembled and should function properly

Benshoof Checkpoints

 (Part 1) Benshoof should have seen your working wiring before you moved on

 (Part 2) Benshoof should have seen your careful drawing before you moved on

 (Part 3) Benshoof should have seen your working Bug Bot