Programming and Problem Solving with Java

(やまだぃちぅ) #1

2.Develop a thorough set of test data for the Incomesapplication as modified in
Exercise 1.


3.Rather than having the application class responsible for extracting the gender
code and salary from the input line, redesign this problem to extend Gender
with two new methods: chargetGender(String inLine)and double
getSalary(String inLine).
Code and test your redesign.


4.Use the Stringmethods valueOf,indexOf, and substringto print only two
decimal places for all floating-point output values in the Incomesapplication. To
accomplish this conversion, you must perform the following tasks:
a.Convert the floating-point value to a string using the valueOfmethod.
b.Find the location of the decimal point using the indexOfmethod.
c. Create a new string that is a substring of the original with only two
characters following the decimal point using the substringmethod.


267
Free download pdf