Table of Contents

Assignment 8

Part 1

Go to pastebin.com


If you have not done so, please put your PasteBin account into your Links page on your Wordpress site.

Create a new PASTE in your own PasteBin account:

Put this code in it:

public class HelloWorld {
	public static void main (String [] args)
	{
		System.out.println("Hello World");
	}
}

Save it as Hello World.

Make sure you select the right options for it:

You can use this as a reference for future Java Projects.


Part 2

Extra References on Eclipse:

You are allowed to work in pairs. No groups of 3, but you can work alone.

Java Materials (Credit: Cameron Alston) - 1 2 3 4 5 6

Lessons 1-6 in a PDF: PDF

Save everything you do in a Paste for YOUR PasteBin, so you can find it later.

Code we went over in class:

 
public class HelloWorld {
 
	// This is my main function
	public static void main (String[] args){
		print("Hello World");
 
		int num1 = 10;
		int num2 = 55;
 
		print("num1 = " + num1);
 
		int num3 = num2;
		num2 = num1;
		num1 = num3;
 
		System.out.println("num1 = " + num1);
 
		// adding two numbers
		System.out.println( add(num1,num2) );
		System.out.println( num1 + num2 );
 
		// subtract
		System.out.println( "difference = " + subtract(num1,num2) );
		print ("PRINT FUNCTION!!!");
 
		int[] array = {2, 4, 6, 2, 4, 1, 88};
 
		for (int i=0;i<array.length;i++){
			print(array[i]);
		}	
	}
 
 
	// This is my add function
	public static int add (int apple, int banana){
		int sum;
		sum = apple + banana;
		return sum;
	}
 
	// This is for subtract
	public static int subtract (int a, int b){
		return a-b;
	}
 
	// This is my print func
	public static void print (Object s){
 
		System.out.println(s);
	}	
}

Check out random!

import java.util.Random;
 
public class HelloWorld {
 
	public static void main (String [] args)
	{
 
		Random rand = new Random();
 
		for (int i=0; i<100; i++)
		    System.out.println(i + " = " + rand.nextInt(2000));
 
 
	}
 
}

Animation