Java Reference
In-Depth Information
Sections 2.17-2.18
2.22
( Random character ) Write a program that displays a random uppercase letter
using the System.CurrentTimeMillis() method.
2.23
( Find the character of an ASCII code ) Write a program that receives an ASCII
code (an integer between 0 and 127) and displays its character. For example, if the
user enters 97 , the program displays character a . Here is a sample run:
69
Enter an ASCII code:
The character is E
*2.24
( Financial application: monetary units ) Rewrite Listing 2.10,
ComputeChange.java, to fix the possible loss of accuracy when converting a
double value to an int value. Enter the input as an integer whose last two digits
represent the cents. For example, the input 1156 represents 11 dollars and 56 cents.
*2.25
( Financial application: payroll ) Write a program that reads the following infor-
mation and prints a payroll statement:
Employee's name (e.g., Smith)
Number of hours worked in a week (e.g., 10)
Hourly pay rate (e.g., 6.75)
Federal tax withholding rate (e.g., 20%)
State tax withholding rate (e.g., 9%)
Enter employee's name:
Enter number of hours worked in a week:
Enter hourly pay rate:
Enter federal tax withholding rate:
Enter state tax withholding rate:
Smith
10
6.75
0.20
0.09
Employee Name: Smith
Hours Worked: 10.0
Pay Rate: $6.75
Gross Pay: $67.5
Deductions:
Federal Withholding (20.0%): $13.5
State Withholding (9.0%): $6.07
Total Deduction: $19.57
Net Pay: $47.92
Section 2.19
*2.26
( Use input dialog ) Rewrite Listing 2.10, ComputeChange.java, using input and
output dialog boxes.
*2.27
( Financial application: payroll ) Rewrite Exercise 2.25 using GUI input and
output dialog boxes.
 
 
Search WWH ::




Custom Search