11/18/2013

BCS2233 OOP: Assignment 2 & 3

ASSIGNMENT 2

1. Write method headers for the following methods:


   a. Computing a sales commission, given the sales amount and the commission rate.
    b. Printing the calendar for a month, given the month and year.
    c. Computing a square root.
    d. Testing whether a number is even, and returning true if it is.
    e. Printing a message a specified number of times.
    f. Computing the monthly payment, given the loan amount, number of years, and annual interest rate.
2. (Analyzing input) Write a program that reads ten numbers, computes their average, and finds out how many numbers are above the average.

3. (Reversing the numbers entered) Write a program that reads ten integers and displays them in the reverse of the order in which they were read.

ASSIGNMENT 3

1. Define the following terms:-
a. class
b. object
c. data
d. properties
e. behaviour
f. method
g. constructor
h. destructor
2.  (The Rectangle class) Design a class named Rectangle to represent a rectangle. The class contains:
Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height.

A string data field named color that specifies the color of a rectangle. Hypothetically, assume that all rectangles have the same color. The default color is white.

A no-arg constructor that creates a default rectangle.

A constructor that creates a rectangle with the specified width and height.

The accessor and mutator methods for all three data fields.

A method named getArea() that returns the area of this rectangle.

A method named getPerimeter() that returns the perimeter.

 Draw the UML diagram for the class. Implement the class. Write a test program that creates two Rectangle objects. Assign width 4 and height 40 to the first object and width 3.5 and height 35.9 to the second object. Assign color red to all Rectangle objects. Display the properties of both objects and find their areas and perimeters.

No comments:

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...