# Calculator program

```public class Calculator extends ConsoleProgram
{
public void run()
{
int sum = first + second;
System.out.println(sum);
}
}
```
1. How many variables are in this program?
2. How many methods are in this program?
3. How many classes are in this program?

Rewrite this program to work in "real" Java below:

What is tricky about the program below?
```public class TrickyJava extends ConsoleProgram
{
public void run()
{
int candyBars = 20;
int friends = 5;
System.out.println("Candy bars: " + candyBars);
System.out.println("Friends: " + friends);
int candyBarsPerPerson = candyBars / friends;
// We expect it to be 4... and it is 4.
System.out.println("Candy per person: " + candyBarsPerPerson);
friends++;
System.out.println("Candy bars: " + candyBars);
System.out.println("Friends: " + friends);
// We expect it to be 3.33.. and it is ..
candyBarsPerPerson = candyBars / friends;
System.out.println("Candy per person: " + candyBarsPerPerson);
}
}```
1. How many variables are in this program?
2. Why is the answer different than expected?
3. What can be changed?

### Paint Program #1:

Write a program to calculate the number of gallons of paint needed to paint a room if:

• One gallon covers 65 square feet
• You should always order an extra gallon or part of a gallon
• The user enters the height and width of the wall in feet to the nearest foot (whole number)
• The room is square with 4 walls.
• Calculate outputs first. 10X8 walls: ______ 15 X 9 walls: _______

### Comparison program:

Given 2 int values, print the smallest number if both numbers are >0, or print the largest number if they are both < 0. Otherwise print "out of range"

```
```