Chapter 2 Helper Sheet

Scanner object knows: How to read from the screen

Package to import: import java.util.Scanner;

How to create a Scanner for your screen:

How to use a Scanner to read from your screen:

Methods that work on Scanner:

NumberFormatter object knows: How to print money

Package to import: import java.text.NumberFormat;

How to create a NumberFormatter for your money:

How to use a NumberFormatter to print to your screen:

DecimalFormatter object knows: How to print decimals

Package to import: import java.text.DecimalFormat;

How to create a DecimalFormatter for your numbers:

How to use a DecimalFormatter to print to your screen:

Different format options:

printf command:

Just like println, but uses variables inside string start % and end character.

%, then size of whole number, then decimal places and then type