Java Reference
In-Depth Information
6.12
( Display characters ) Write a method that prints characters using the following
header:
public static void printChars( char ch1, char ch2, int
numberPerLine)
This method prints the characters between ch1 and ch2 with the specified num-
bers per line. Write a test program that prints ten characters per line from 1 to Z .
Characters are separated by exactly one space.
*6.13
( Sum series ) Write a method to compute the following series:
1
2 +
2
3 + c +
i
m ( i )
=
i
+
1
Write a test program that displays the following table:
i
m(i)
1
0.5000
2
1.1667
...
19
16.4023
20
17.3546
*6.14
( Estimate
p ) p can be computed using the following series:
1) i + 1
VideoNote
Estimate p
-
1
3
1
5
1
7
1
9
1
11
(
m ( i )
=
4
¢
1
-
+
-
+
-
+ g +
2 i
-
1
Write a method that returns m(i) for a given i and write a test program that dis-
plays the following table:
i
m(i)
1
4.0000
101
3.1515
201
3.1466
301
3.1449
401
3.1441
501
3.1436
601
3.1433
701
3.1430
801
3.1428
901
3.1427
*6.15
( Financial application: print a tax table ) Listing 3.5 gives a program to compute
tax. Write a method for computing tax using the following header:
public static double computeTax( int status, double taxableIncome)
 
 
Search WWH ::




Custom Search