Part Zero - Review

Make a program that adds two int's and prints them out

Try to write out the main method yourself but if you forgot just click here

Part One

Just like in math class certain operators take precedence over others. What do you think the value of this expression would be?

4 + 5 * 6 + 2

Try it in Dr.Java to find out. Now try to get the additions to happen before the multiplication.

Part Two

Alot of times were going to want to change the value of a variable. Lets say we wanted to add three to the value of an int

int x = 5;

//we can do it like this
x = x + 3;

// or this..
x+=3;
       

Java also has special operators for incrementing by 1. ++ and -- increment and decrement by 1 respectively.

Part Three

We have simple math covered but obviously you're going to need to know more in order to do most programs. Java provides the Math class for this and there's two types that let you express non-whole numbers: float and double.

Write a program that solves the Pythagorean theorem using Math.sqrt() and Math.pow()

Home Work

1. Write a program that provides the following output:

********************************
*   Programming Assignment 2   *
*      Computer Science 1      *
*    Author : ""your name""    *
*     Due Date : 9/21/2011     *
********************************
        

2. Write a program that will calculate the average grade for the class given the following students:

Jeff    :  85.5
Abed    : 100.0
Shirley :  91.3
Troy    :  79.6
Peirce  :  45.2
        

Make the output look like this

The average grade is ""answer""

.. and if you want to learn more on your own

Sign up for StackOverflow and come to the next Computer Society meeting