Study Display 4.4 (2nd ed. and 3rd ed.) or Display 4.2 & Display 4.3 (1st ed.) and then1. Comment out date.setDate(6, 17, year); by // date.setDate(6, 17, year);2. At the next line below, add date.readInput();3. Run the program again. Fix any problems you may encouter along the way.4. At the last line of your program, add System.out.println(date.month);and see what happens. Why?
2009年3月30日 星期一
2009年3月29日 星期日
2009年3月26日 星期四
Lab Cosine
Lab Fibonacci
List the first 100 numbers and the ratio ofa 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
2009年3月22日 星期日
2009年3月16日 星期一
Lab Finding the max of a list of numbers
Lab Tax Calculation
Study Display 3.1. Based on the income tax rate in Taiwan,calculate the income tax of a person whose annual income is 1,000,000 or 2,000,000.
2009年3月15日 星期日
2009年3月9日 星期一
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;ChangeScanner keyboard= new Scanner(System.in);intoBufferedReader 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
2009年3月8日 星期日
Homework 3-2-2009
1. Write a program that can reverse the order of an input string. For example, if you input "ab", it will output "ba". If you input "abcdefg", it should return "gfedcba".
2. Write a program that can print names alternatively. The names are in the format of "First Name + Last Name" or "Last Name, First Name". For example, if you input "Walt Savitch", your program will output "Savitch, Walt". If you input "Savitch, Walt", your program will output "Walt Savitch".
2. Write a program that can print names alternatively. The names are in the format of "First Name + Last Name" or "Last Name, First Name". For example, if you input "Walt Savitch", your program will output "Savitch, Walt". If you input "Savitch, Walt", your program will output "Walt Savitch".
2009年3月2日 星期一
work3
Do Project 5 of Chap. 1 on Page 56.Write a program that starts with a line of text and then outputs that line of text with the first occurrence of "hate" changed to "love". For example, a possible sample output might beThe line of text to be changed is:I hate you.I have rephrased that line to read:I love you.
2009年3月1日 星期日
HOMEWORK#2
1. 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.
2. Write a Java program that displays the results of the expressions 15/4, 4/15, 15%4, 4%15. Calculate the values of these expressions manually to verify that the displayed values are correct.
Hint: There are 5280 feet in a mile.
2. Write a Java program that displays the results of the expressions 15/4, 4/15, 15%4, 4%15. Calculate the values of these expressions manually to verify that the displayed values are correct.
訂閱:
文章 (Atom)