CIS 283 - Programing assignment11 Email: jperezc at calstatela.edu

This is similar to programming challenge 13, page 320 of our book

For this assignment you are going to write the code for the following class:

• TestIsPrime

### Here are the specifications of class TestIsPrime:

Methods of class TestIsPrime:

isPrime
returns: true if its argument is a prime number
arguments: an int number
what it does:

1. A prime number is a number that is evenly divisible only by itself
and 1. For example, the number 5 is prime because it can be evenly
divided only by 1 and 5. The number 6, however, is not prime because
it can be divided evenly by 1, 2, 3, and 6. Write a method named
isPrime , which takes an integer as an argument and returns true if
the argument is a prime number, or false otherwise.

Example (see details in main method below):

System.out.println(T.isPrime(3));

would print true

System.out.println(T.isPrime(4));

would print false

TIP: Recall that the % operator divides one number by another, and
returns the remainder of the division. In an expression such as num1 % num2 , the % operator will return 0 if num1 is evenly divisible by
num2 .

returns: a char that can be either A, B, C, D, or F
arguments: one double called n
what it does: Use the isPrime method that you wrote in order to print a list of all prime numbers less than n

Example:

would print:

```1
2
3
5
7```

• create a folder called Assignment11
• create a file called Square.java and save it in folder Assignment11
• compile all java files in folder Assignment11
• type the following command in the DOS prompt window:
• java Test11

• tests will be run on your code and appropriate messages will be printed out showing which tests passed and which failed. At the end the program will tell you which option to choose in the moodle quizz corresponding to programming exercise 11
• You must use Test11.print or Test11.println instead of System.out.print and System.out.println. Use Test11_java6.print and Tes11_java6.println if you are using java6.

You could use the following main method in order to test your program. You don't need to use it, you don't need to show it to me or submit it. Use it if you want to test your code:

```    public static void main(String[] args){ 	    TestIsPrime T = new TestIsPrime();    	System.out.println(T.isPrime(3));	    System.out.println(T.isPrime(4));
int n = 10;  	System.out.println("=== list of primes less than n = " + n); 	T.primeNumberList(n);    } ```
` `

This main method could be a method of your TestIsPrime class. In that case you could test your class by typing:

java TestIsPrime

 Email: jperezc at calstatela.edu