485620 Java programming arrays classes and objext

STEP 1: Cylinder (20 points)

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 accessor 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).

STEP 2: Date (20 points)

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

Beceriler: Her şey Kabul, Java, PHP

Daha fazlasını gör: date increment java program, variables in programming, tests java programming, test iteration, programming variables, programming object, programming methods, programming method, programming loop, programming error, programming classes, programming class, programming array, program for java programming, php programming test, objects in programming, object in programming, method programming, math programming, math in programming, math and programming, loop programming, java programming test, java programming program, java programming classes

İşveren Hakkında:
( 8 değerlendirme )

Proje NO: #2231530



Ready to send you code.

%selectedBids___i_period_sub_7% gün içinde 20%project_currencyDetails_sign_sub_9% %project_currencyDetails_code_sub_10%
(200 Değerlendirme)