CSIS 212 Programming Assignment 7 Rectangle Class

Exercise 8.4 JHTP (Rectangle Class): Create a class Rectangle with attributes length and width, each of which defaults to 1. Provide methods that calculate the rectangle’s perimeter and area. Use set and get methods for both length and width. The set methods will verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0. Write a program to test class Rectangle.

This assignment is due by 11:59 p.m. (ET) on Monday.

Notes:
1. In the test class write code to create and print a menu that returns a value corresponding to the menu choice.
2. Also in the test file, remember to code a Try Catch Illegial Argument Expection to determine if the user entered a length and width of 0.0-20.



This slideshow requires JavaScript.



This assignment includes a zip document.

  • Attachments
  • Preview random excerpt
    xxxxxx xxxxxx xxxxxxxxx() {
    xxxxxx xxxx.xxxxxx;
    }
    xxxxxx xxxx xxxxxxxxx(xxxxxx xxxxxx) xxxxxx xxxxxxxxx {
    xx
    (length <
    x
    || length >
    xx
    )
    xxxxx
    xxx
    Exception("Invalid length,
    xxxxx
    must larger than 0.0 and less than 20.0");
    xxxx
    .length = length; }
    xxxxxx
    double getWidth() {
    xxxxxx
    this.width; }
    xxxxxx
    xxxx
    xxxxxxxx
    (double
    xxxxx
    )
    xxxxxx
    Exception {
    xx (xxxxx < 0 || xxxxx > 20)
    xxxxx xxx xxxxxxxxx("xxxxxxx xxxxx, xxxxx xxxx xxxxxx xxxx 0.0 xxx xxxx xxxx 20.0");
    xxxx.xxxxx = xxxxx;
    - - - more text follows - - -
    Preview random excerpt
    xxxxxx.xxx.xxxxxxx("5. xxxx");
    }
    xxxxxx xxxxxx xxxx xxxx(xxxxxx[] xxxx) {
    xxxxxxx xxxxx = xxx xxxxxxx(xxxxxx.xx);
    xxxxxxxxx
    rect =
    xxx
    xxxxxxxxx
    ();
    xxx
    {
    xxx
    choice = 0;
    xxxxx
    (
    xxxxxx
    !=
    x
    ) {
    xxxxxx
    .out.println("Enter your choice (1-5):");
    xxxxxx
    = input.nextInt();
    xxxxxx
    (choice) {
    xxxx
    1:
    xxxxxx
    .out.print("Enter length: ");
    xxxxxx
    length =
    xxxxx
    .nextDouble();
    xxxx.xxxxxxxxx(xxxxxx);
    xxxxx;
    xxxx 2:
    - - - more text follows - - -



Purchasing Instruction
Price: $15
Buy Now

Buy More Save More
Buy at least TWO items & save up to 30% OFF your ENTIRE order!
Rack up instant rebates in your shopping cart. Simply add items to your cart, and see the savings add up.
Discounts will automatically be applied on eligible orders.

Add to Cart
FLASH SALE
$89

$112 Save $23
CSIS212 Entire Course