567646 Arrays Classes and Objects 2

In Corso Pubblicato May 23, 2012 Pagato alla consegna
In Corso Pagato alla consegna

Deliverable: Program files for each of the two programs:

1. Cylinder

2. Date

Format needed at the top of each program file:

/*********************************************************

Program Name: Cylinder

Programmers Name: Name

Program Description: This program will calculate volume a cylinder, etc...

************************************************************/

Miscellaneous deliverables:

1. The programs MUST have the same names as the assignment title.

2. Each Java source file (*.java) must include a corresponding class file (*.class) program as evidence of success.

3. You must use a Zipped Folder to send your Weekly Assignment to the DropBox. Do not send subfolders within your zipped folder. Place ALL of the .java and .class files for the week into the one zipped folder. The Zip folder should be named: YourLastName Week 3, and this Zip folder will contain all the weekly programming assignments.

4. Put all program source files in a word document with a screen shot of all your program output.

5. For programs that contain multiple files, zip up all the files into a standalone zip file. Then include the program zip file in the Assignment zip file (that is, you will have zip files, within an enclosing zip folder.)

Instructions:

Create a class called [url removed, login to view] that contains two double-precision instance variables named radius and height. The class should include a constructor that initializes the radius and height variables. Additionally, there should be two accessory methods that return an object's radius and height, respectively, and a class method named volume() that returns the volume of a Cylinder object. The volume of a cylinder is given by its radius squared times its height times Pi. You can either use the value 3.1416 for Pi or use the Java provided value named Math.PI.

Write a class called [url removed, login to view] and declare an array of three Cylinder objects to call the methods you declared in the Cylinder class. Make sure that all class methods are called from main(). Have main() display the value returned by volume() and verify the returned value by hand calculations (paper/pencil).

Create a program called [url removed, login to view] to perform error-checking on the initial values for instance: fields month, day and year. Also, provide a method nextDay() to increment the day by one. The Date object should always remain in a consistent state. Write a program that tests the nextDay method in a loop that prints the date during each iteration of the loop to illustrate that the nextDay method works correctly. Test the following cases:

a) incrementing into the next month.

b) incrementing into the next year.

Sample program output:

Checking increment

Date object constructor for date 11/27/1988

Incremented Date:11/28/1988

Incremented Date:11/29/1988

Incremented Date:11/30/1988

Day 31 invalid. Set to day 1.

Incremented Date:12/1/1988

Incremented Date:12/2/1988

...

Incremented Date:12/30/1988

Incremented Date:12/31/1988

Day 32 invalid. Set to day 1.

Incremented Date:1/1/1989

Incremented Date:1/2/1989

Incremented Date:1/3/1989

Incremented Date:1/4/1989

Incremented Date:1/5/1989

Incremented Date:1/6/1989

Java Odd Jobs PHP

Rif. progetto: #2313610

Info sul progetto

Progetto a distanza Attivo Jul 11, 2012