Java Reference
In-Depth Information
balance, and new balance or an appropriate error message. Test your
program by running it five times, using the following data:
46728 S 1000 2700
87324 C 1500 7689
79873 S 1000 800
89832 C 2000 3000
98322 C 1000 750
13. Write a program that implements the algorithm given in Example 1-2
(Chapter 1), which determines the monthly wages of a salesperson.
14. The number of lines that can be printed on a piece of paper depends on the
paper size, the point size of each character in a line, whether lines are
double-spaced or single-spaced, the top and bottom margin, and the left
and right margins of the paper. Assume that all characters are of the same
point size, and all lines are either single-spaced or double-spaced. Note that
1 inch ΒΌ 72 points. Moreover, assume that the lines are printed along the
width of the paper. For example, if the length of the paper is 11 inches and
the width is 8.5 inches, then the maximum length of a line is 8.5 inches.
Write a program that calculates the number of characters in a line and the
number of lines that can be printed on a paper based on the following input
from the user:
a. The length and width, in inches, of the paper.
b. The top, bottom, left, and right margins.
c. The point size of a line.
d. If the lines are double-spaced, then double the point size of each
character.
15. Write a program that calculates and prints the bill for a cellular telephone
company. The company offers two types of service: regular and premium.
Rates vary based on the type of service and are computed as follows:
4
Regular service: $10.00 plus first 50 minutes are free. Charges for over 50
minutes are $0.20 per minute.
Premium service: $25.00 plus:
a. For calls made from 6:00 a.m. to 6:00 p.m., the first 75 minutes are free;
charges for over 75 minutes are $0.10 per minute.
b. For calls made from 6:00 p.m. to 6:00 a.m., the first 100 minutes are
free; charges for over 100 minutes are $0.05 per minute.
Your program should prompt the user to enter an account number, a service
code (type char ), and the number of minutes the service was used. A service
code of r or R means regular service; a service code of p or P means premium
service. Treat any other character as an error. Your program should output
the account number, type of service, number of minutes the telephone
Search WWH ::




Custom Search