Lesson 2 - Basic calculations
On the first lesson we simply printed things on the console. On this lesson we will keep printing things on the console, but this time we will print some calculations. This is a very simple lesson, but your first chance to do it all by yourself.
What you are going to learn
- How to express simple calculations in Java
Instructions
The process is the same:
- Start the VM (go back to the clean state if needed)
- Log into the VM
- Download the lesson using 02j-get-lesson
- Run Maven using mvn
- Make changes until you get a BUILD SUCCESS
Theory
Doing calculations in Java is straightforward. You just need to type them like:
System.out.println(1 + 2);
It is this simple. Yes, you will complete this lesson in a couple minutes, hopefully. We are actually still learning how to find our way on the environment.
In this lesson you are going to do simple calculations using the variables x and y that already came declared. Therefore, you don't need to repeat the numbers in each calculation. Instead, use the variable names.