Define a Complex class and write an object oriented program to compute (2+3i)+(4+5i) in Java.
2008年5月26日 星期一
Homework 5-19-2008
1. Do Temperature Project, which is Project 7 (3rd, 2nd ed.) or Project 3 (1st ed.).
Write a Temperature class that has two instance variables: a temperature value(a floating-point number) and a character for the scale, either C for Celsius or F for Fahrenheit. The class should have four constructor methods: one for each instance variable(assume zero degrees if no value is specified and Celsius if no scale is specified), one with two parameter for the two instance variable, and a no-argument constructor (set to zero degrees Celsius). Include the following:
Write a Temperature class that has two instance variables: a temperature value(a floating-point number) and a character for the scale, either C for Celsius or F for Fahrenheit. The class should have four constructor methods: one for each instance variable(assume zero degrees if no value is specified and Celsius if no scale is specified), one with two parameter for the two instance variable, and a no-argument constructor (set to zero degrees Celsius). Include the following:
2008年5月25日 星期日
lab Fraction equality test
Write a program to implement a method that can check whether 2 fractions are equal. You will implement a class called Fraction consisting of a numerator and a denominator. The equality test of 2 fractions should return a boolean value.
Use the following as the tests. 1/2 and 2/4
Use the following as the tests. 5/6 and 6/7
Use the following as the tests. 1/2 and 2/4
Use the following as the tests. 5/6 and 6/7
2008年5月19日 星期一
lab Fraction Addition
lab counter
Define a class called Counter whose objects count things. An object of this class records a count that is a nonnegative integer. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1. Include an accessor method that returns the current count value and a method that outputs the count to the screen. Write a program to test
counter.reset();
counter.inc();
counter.inc();
counter.dec();
counter.output();
counter.reset();
counter.inc();
counter.inc();
counter.dec();
counter.output();
Class Definition 3
訂閱:
文章 (Atom)