顯示具有 java-lab 標籤的文章。 顯示所有文章
顯示具有 java-lab 標籤的文章。 顯示所有文章

2008年6月9日 星期一

Lab Static method

Define a Complex class with a static method for computing complex addition. Use (2+3i)+(4+5i) in your test.




Lab Java Constructor

Use Display 4.14 to call 4.13 (2nd ed.) or
Display 4.12 to call 4.11 (1st ed.).

After you finish the above, try the following

Date birthday = new Date("Jan",1,2000);
birthday.Date("Feb",1,2000);
birthday.setDate("Feb",1,2000);
birthday=new Date("Mar",1,2000);






2008年6月2日 星期一

Lab Overloading

Do Display 4.11


2008年5月26日 星期一

Lab ADT, accessor, mutator

Define a Complex class and write an object oriented program to compute (2+3i)+(4+5i) in Java.


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

2008年5月19日 星期一

lab Fraction Addition

Write a program to implement a method that can do additions of 2 fractions. You will implement a class called Fraction consisting of a numerator and a denominator.


The additions of 2 fractions should be equal to a fraction.
Hints:
Fraction f1, f2;
f1.add(f2);


Use 1/2+1/3 as the test.

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();

2008年4月28日 星期一

lab class definition 2

Study Display 4.4 (2nd ed. and 3rd ed.) or Display 4.2 & Display 4.3 (1st ed.) and then
1. Comment out date.setDate(6, 17, year); by // date.setDate(6, 17, year);



Study Display 4.4 (2nd ed. and 3rd ed.) or Display 4.2 & Display 4.3 (1st ed.) and then
1. Comment out date.setDate(6, 17, year); by // date.setDate(6, 17, year);

4. At the last line of your program, add System.out.println(date.month);
and see what happens. Why?

2008年4月14日 星期一

lab class definition

Study Display 4.1 and then do Self-Test Exercise 1.


2008年4月7日 星期一

Lab 9*9

Write a program to generate the following table of arithmetic expressions

Lab Fibonacci numbers

Do Project 3.3 (1st ed.) or Project 6 (2nd ed. & 3rd ed.) Fibonacci numbers.
List the first 100 numbers and the ratio of
a number to its previous number, such as 1/1 = 1, 2/1 = 2, 3/2 = 1·5, 5/3 = 1·666..., 8/5 = 1·6, 13/8 = 1·625, 21/13 = 1·61538....

Want to know more about Fibonacci number

Lab Finding the max of three numbers

Write a program to decide the max number of the three input number.


2008年3月22日 星期六

Lab Keyboard input

Rewrite Display 2.6 using BufferedReader.

You need to import the following packages in the first place.

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

Change

Scanner keyboard= new Scanner(System.in);

into

BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));

String inputString = keyboard.readLine();

Note the Main method needs IOException handling as follows:

public static void main (String[] args) throws IOException


2008年3月17日 星期一

Lab Scanner

Do Display 2.6.

2008年3月10日 星期一

Lab: Simple Calculation

Suppose you are a landscape architect who charges $5,000 per mile to landscape a highway, and suppose you know the length in feet of the high way you are working on. Write a Java program to calculate the price you charge when the length is 6000 and 4000, respectively.
Hint: There are 5280 feet in a mile


2008年3月3日 星期一

Lab 2 Java for Scientific Computation

Do Project 4 on Page 55. (3rd Edition)

Do Project 4 on Page 56. (2nd Edition)

Do Project 1 on Page 54. (1st Edition)

artificial sweetener 人工代糖(過量可以致癌)
diet soda pop 減肥可樂
lose weight 減肥

Lab Get familiar with JBuilder

課本 Display 1.1