Java Reference
In-Depth Information
Enter string s1: ABCD
Enter string s2: BDC
BDC is not a substring of ABCD
*4.23
(
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., 9.75)
Federal tax withholding rate (e.g., 20%)
State tax withholding rate (e.g., 9%)
A sample run is shown below:
Enter employee's name: Smith
Enter number of hours worked in a week: 10
Enter hourly pay rate: 9.75
Enter federal tax withholding rate: 0.20
Enter state tax withholding rate: 0.09
Employee Name: Smith
Hours Worked: 10.0
Pay Rate: $9.75
Gross Pay: $97.5
Deductions:
Federal Withholding (20.0%): $19.5
State Withholding (9.0%): $8.77
Total Deduction: $28.27
Net Pay: $69.22
*4.24
(
Order three cities
) Write a program that prompts the user to enter three cities and
displays them in ascending order. Here is a sample run:
Enter the first city: Chicago
Enter the second city: Los Angeles
Enter the third city: Atlanta
The three cities in alphabetical order are Atlanta Chicago Los Angeles
*4.25
(
Generate vehicle plate numbers
) Assume a vehicle plate number consists of three
uppercase letters followed by four digits. Write a program to generate a plate
number.
*4.26
(
Financial application: monetary units
) Rewrite ListingĀ 2.10, ComputeChange.
java, to fix the possible loss of accuracy when converting a float value to an
int
value. Read the input as a string such as
"11.56"
. Your program should extract
the dollar amount before the decimal point and the cents after the decimal amount
using the
indexOf
and
substring
methods.
Search WWH ::
Custom Search