# Evidence For Chapter 8

Topics: Number, Automotive industry, Class Pages: 4 (501 words) Published: January 11, 2015
﻿H/W Evidence for chapter 8 10/01/15
Euan Sarson (10W)

8.1
package chapter8;

public class PrimitiveIntegerArray {
public static void main (String [] args){
int[] myLuckyNumber = new int[5];

myLuckyNumber[0] = 9;
myLuckyNumber[1] = 11;
myLuckyNumber[2] = 38;
myLuckyNumber[3] = 2;
myLuckyNumber[4] = 991;

System.out.println(myLuckyNumber[0]);
System.out.println(myLuckyNumber[1]);
System.out.println(myLuckyNumber[2]);
System.out.println(myLuckyNumber[3]);
System.out.println(myLuckyNumber[4]);

}
}

8.2
package chapter8;
import java.util.Random;
import java.util.Scanner;

public class Lottery {
public static void main (String [] args){
Scanner scanner = new Scanner(System.in);
Random rand = new Random();

int[] number = new int[6];
number[0] = rand.nextInt(54) + 1;
number[1] = rand.nextInt(54) + 1;
number[2] = rand.nextInt(54) + 1;
number[3] = rand.nextInt(54) + 1;
number[4] = rand.nextInt(54) + 1;
number[5] = rand.nextInt(54) + 1;

int[] guess = new int[6];
guess[0] = scanner.nextInt();
guess[1] = scanner.nextInt();
guess[2] = scanner.nextInt();
guess[3] = scanner.nextInt();
guess[4] = scanner.nextInt();
guess[5] = scanner.nextInt();

System.out.println("---> The winning lottery numbers are:");
System.out.println(number[0]+", "+number[1]+", "+number[2]+", "+number[3]+", "+number[4]);
System.out.println("And the bonus ball is: "+number[5]);

System.out.println("Would you like to see what you have...