Java Reference
In-Depth Information
Use this method to write a program that prints a tax table for taxable income from
$50,000 to $60,000 with intervals of $50 for all the following statuses:
Taxable
Income
Single
Married Joint
or Qualifying
Widow(er)
Married
Separate
Head of
a House
50000
8688
6665
8688
7353
50050
8700
6673
8700
7365
...
59950
11175
8158
11175
9840
60000
11188
8165
11188
9853
Hint : round the tax into integers using Math.round (i.e., Math
.round(computeTax(status, taxableIncome) ).
*6.16
( Number of days in a year ) Write a method that returns the number of days in a
year using the following header:
public static int numberOfDaysInAYear( int year)
Write a test program that displays the number of days in year from 2000 to 2020.
Sections 6.10-6.11
*6.17
( Display matrix of 0s and 1s ) Write a method that displays an n -by- n matrix using
the following header:
public static void printMatrix( int n)
Each element is 0 or 1, which is generated randomly. Write a test program that
prompts the user to enter n and displays an n -by- n matrix. Here is a sample run:
Enter n: 3
0 1 0
0 0 0
1 1 1
**6.18
( Check password ) Some websites impose certain rules for passwords. Write a
method that checks whether a string is a valid password. Suppose the password
rules are as follows:
A password must have at least eight characters.
A password consists of only letters and digits.
A password must contain at least two digits.
Write a program that prompts the user to enter a password and displays Valid
Password if the rules are followed or Invalid Password otherwise.
*6.19
( The MyTriangle class ) Create a class named MyTriangle that contains the
following two methods:
/** Return true if the sum of any two sides is
* greater than the third side. */
public static boolean isValid(
double side1, double side2, double side3)
 
 
Search WWH ::




Custom Search