Write a program checkerboardjava that takes an integer


1. Write a program Checkerboard.java that takes an integer command-line argument N, and uses two nested for loops to print an N-by-N "checkerboard" pattern like the one below: a total of N2 asterisks, where each row has 2N characters (alternating between asterisks and spaces).

The following are sample executions of the program, with the expected output.> java Checkerboard 4
* * * *
* * * *
* * * *
* * * *

> java Checkerboard 5
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *

2. Testing a Leap Year library.

This exercise is about code testing. You are given a ready-made library that has some ‘deliberate bugs'. Your task is to prove that by collecting the evidence (i.e. finding for which input the code produces an incorrect output.)

The code to be tested is provided in class form (i.e. you do not have access to the source code). Thus you are asked to implement black-box testing.

This is how you use the LeapYear code from command line:

> java LeapYear
Usage: 'java LeapYear ' (where 'year' is a valid integer in [- 1000 to 9999])

> java LeapYear 2015 false

Now, your task is to write a separate class, name it TestLeapYear and store it in a file named TestLeapYear.java, that will extensively test the LeapYear program and produce the evidence showing that it does not work for all possible input.

You are advised to start by extending the code below (make sure you use the same folder as LeapYear.class):

public class TestLeapYear
{
public static void main(String[] args)
{
boolean isLeap = LeapYear.isLeapYear(2015);
if(isLeap) // we know year 2015 is not a leap year, so we expect a false
{
System.out.println("2015 -> True: Something is wrong!");
}
else
{
System.out.println("2015 -> False: Seems to work ok!");
}
}
}

Submission guidelines/checklist

- You should submit your assignment in electronic form via Blackboard.

- You should name every program as suggested, e.g. Quadratic.java

- The header of your program should include comments with the author name (yourself) & email, a quick description of the program, and any other details that you would like me to know (e.g. whether it compiles, how far you got in your assignment, etc.).

- You should also include comments in the code where appropriate (there is no need for excessive use of comments, but add them where they add clarity).

- Use the coding conventions and readability suggestions discussed in the lectures.

- In your communications, use your UCLAN email exclusively (other email addresses like hotmail, live, gmail, etc.) will be ignored.

- When uploading your submission, make sure you do not forget to attach your programs.

- The submitted programs should be the result of your own personal work. You can look-up the lecture slides, the textbook and even the Web for examples. But you need to be ready to defend your solutions verbally, and even reproduce them on your own in exam conditions.

- Exercises that do not compile are marked up to 40% max. Exercises that do not always produce the desired output or include unnecessary complexity are marked up to 60% max. Exercises that do not use correct styling, coding conventions, appropriate variable naming and comments, are marked up to 80% max. Failing to follow these guidelines will also affect your mark.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a program checkerboardjava that takes an integer
Reference No:- TGS01164398

Now Priced at $30 (50% Discount)

Recommended (96%)

Rated (4.8/5)