Java Reference
In-Depth Information
Enter a genome string:
no gene is found
TGTGTGTATAT
*9.28
( Calculator ) Revise Listing 9.5, Calculator.java, to accept an expression in which
the operands and operator are separated by zero or more spaces. For example, 3+4
and 3 + 4 are acceptable expressions.
*9.29
( Business: check ISBN-13 ) ISBN-13 is a new standard for identifying topics. It
uses the 13 digits The last digit, is a check-
sum, which is calculated from the other digits using the following formula:
d 1 d 2 d 3 d 4 d 5 d 6 d 7 d 8 d 9 d 10 d 11 d 12 d 13 .
d 13 ,
10
-
( d 1 +
3 d 2 +
d 3 +
3 d 4 +
d 5 +
3 d 6 +
d 7 +
3 d 8 +
d 9 +
3 d 10 +
d 11 +
3 d 12 ) % 10
If the checksum is 10 , replace it with 0 . Your program should read the input as a
string. Here are sample runs:
Enter the first 12 digits of an ISBN-13 as a string:
978013213080
The ISBN-13 number is 9780132130806
Enter the first 12 digits of an ISBN-13 as a string:
978013213079
The ISBN-13 number is 9780132130790
*9.30
( Capitalize first letter of each word ) Write the following method that returns a
new string in which the first letter in each word is capitalized.
public static void title(String s)
Write a test program that prompts the user to enter a string and invokes this
method, and displays the return value from this method. Here is a sample run:
Enter a string:
The new string is: London England 2015
london england 2015
Note that words may be separated by multiple blank spaces.
*9.31
( Swap case ) Write the following method that returns a new string in which the
uppercase letters are changed to lowercase and lowercase letters are changed to
uppercase.
public static String swapCase(String s)
Write a test program that prompts the user to enter a string and invokes this
method, and displays the return value from this method. Here is a sample run:
Enter a string:
The new string is: i'M HERE
I'm here
 
Search WWH ::




Custom Search