Testing a leap year library

Assignment Help JAVA Programming
Reference no: EM13879014

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 <year>' (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.

Reference no: EM13879014

Questions Cloud

Problem regarding the normal shock stands : Air flows through a duct as in Fig P9.84, where A1 = 24 cm2, A2 = 18 cm2, and A3 = 32 cm2. A normal shock stands at section 2.
The air force ignored marketing costs : Alameda Instruments (AI) has offered to supply the Air Force with computer monitors at cost plus 20 percent.
Calculate optimal price, and profit for organization : Assuming that the firm acts as a monopolist, calculate the optimal price, quantity, and profit (i.e., TR - TC) for the organization. After using algebra to find the solution, present your results graphically.
What are the benefits and costs of fdi to the host country? : What are the benefits and costs of FDI to the host country?
Testing a leap year library : 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
Determine the moment of that force : A mechanic uses a piece of pipe AB as a lever when tightening an alternator belt. When he pushes down at A, a force of 580 N is exerted on the alternator B. Determine the moment of that force about bolt C if its line of action passes through O.
Write paper about hatshepsut : Write a a 3-4 pages paper about "Hatshepsut" c. 1473 - 1458 B.C. (18th Dynasty)
Determine the marginal cost of milk production : How have total revenues changed if the actual total production of milk remains unchanged?
Critically analyse the possible effects of e-commerce : Examine the extent to which the role and nature of management accountants might differ within the public and private sectors. Critically analyse the possible effects of e-commerce on the role of the manage- ment accountant.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write ijvm program to multiply two hexadecimal numbers

Write the IJVM program that multiplies two (hexadecimal) numbers. The user inputs the hex numbers and the result is printed out. The program then accepts another pair of numbers.

  What position along the chord does minimum pressure occur

At what position along the chord does the minimum pressure occur? What is special about the point where C p is a maximum?

  Part 1product maintenanceyoull create a series of pages

part 1product maintenanceyoull create a series of pages that allow you to add update or delete a product thats

  A common useful equation

In physics, a common useful equation for finding the position s of a body in linear motion at a given time t, based on its initial position s0, initial velocity v0, and rate of acceleration a, is the following: ??= ??0+??0??+12????2. Write code to de..

  Menu based program to maintain student records

Write a menu based program to maintain student records. Your program should take the following inputs: 1. Student first name (max. 20 characters) 2. Student last name, (max. 20 characters) 3. Student scores (float/double), eg. 85.4 Problem

  To report the amount of the fine

To report the amount of the fine, which is $25 for the first hour or pan of an hour that the car is illegally parked, plus $10 for every additional hour or part of an hour that the car is illegally parked

  Java application to carry out additions and subtractions

Design a Java application to carry out additions and subtractions for numbers of any length. A number is represented as an object which includes a sign and two strings for the whole and decimal parts of the number.

  Compute the correct number of square feet needed

The Carpet House owner wants to put a carpet calculator on his website so that visitors can estimate the amount of carpet they will need to purchase.

  Pacman style game with clara

The major assignment involves producing a Pacman style game with Clara using the Greenfoot files that are given to you.

  What purpose does the wbs serve

What purpose does the WBS serve? Describe the structure of a WBS. How does a WBS contribute to accurate estimates?

  Extend the vending machine

Your task for this assignment is to extend the "Vending Machine" you wrote for assignment seven to add the ability to hold the snacks

  Calculates the cutoff frequency in a simple rc circuit

Write a simple Java application which calculates the cutoff frequency in a simple RC circuit

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd