# Arithmetic Operations

We have some quantity of an item to sell. We want to package it by the dozen. To find how many dozen we can sell and how many we will have left over we must use integers.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| //Find how many dozen and how many left over for a quantity
package dozens;
import java.util.*;
public class Dozen {
public static void main(String[] args) {
Scanner keyboard=new Scanner(System.in); //do just once
int quantity,dozen;
System.out.print("How many do you have:");
int quantity=keyboard.nextInt();
int dozen=quantity/12;
System.out.println("You will have "+dozen+" dozen.");
System.out.println("You will have "+quantity%12+" left over.");
}//main
}//package |

CODEHow many do you have? 50
You will have 4 dozen.
You will have 2 left over.

Remember, you should try doing each of these programs on your own. Get it to work, break it, modify it, then try to write it on your own!