Assignment 0: Basic Java

Purpose

Overview

You will write a class called A0 that contains 3 public methods that perform the functions described below. You may want to write other methods to act as helpers.

You will also write a class called A0driver that will test your three methods.


Question 1:

Write a method called isEvenAscending that takes an array of integers as a parameter and returns true if the array of integers contains a list of even integers in ascending order, and false otherwise.

The following are valid sequences of ascending even integers:

The following are not valid sequences of ascending even integers:


Question 2:

Write a method called isSquareSequence that takes an array of integers as a parameter, and returns true if the array of integers is a sequence of squares and false otherwise.

A sequence of squares is defined as

         2       2       2
        k , (k+1) , (k+2) , ...

So the following are sequences of squares:

But the next set are not sequences of squares


Question 3:

Write a method called isPalindrome that takes a String as a parameter and returns true if the string is a palindrome and false otherwise.

A palindrome is a word, phrase or sentence that reads the same forward and backward.

Here are some examples of palindromes:

See palindromes.org for a longer list.

Note that spaces and punctuation don't count. Also a palindrome is case insensitive (A equals a).

Your method must not be recursive (don't worry if you don't know what recursive means), and it must not modify the string parameter, or create a temporary array or string. (The purpose of these restrictions is to get you to think about how to traverse the string.)


Test cases

Your A0driver class must thoroughly test each of the methods. This means that you will need to think of a set of test cases that cover most of the possibilities. You want to aim for the smallest set of test cases that covers the most possible inputs.

What to hand in:

You will submit two files electronically: A0.java and A0driver.java. Electronic submission instructions will follow.

Please note that approximately 30\% of the marks will be allocated to programming style and comments.


Last modified: Mon Sep 9 22:51:02 EDT 2002