Java Reference
In-Depth Information
P ROGRAMMING E XERCISES
Section 31.2
*31.1
( Loan server ) Write a server for a client. The client sends loan informa-
tion (annual interest rate, number of years, and loan amount) to the server
(see Figure  31.17a). The server computes monthly payment and total pay-
ment, and sends them back to the client (see Figure 31.17b). Name the client
Exercise31_01Client and the server Exercise31_01Server.
(a)
(b)
F IGURE 31.17
The client in (a) sends the annual interest rate, number of years, and loan amount to the server and
receives the monthly payment and total payment from the server in (b).
*31.2
( BMI server ) Write a server for a client. The client sends the weight and
height for a person to the server (see Figure  31.18a). The server computes
BMI (Body Mass Index) and sends back to the client a string that reports the
BMI (see Figure 31.18b). See Section 3.8 for computing BMI. Name the client
Exercise31_02Client and the server Exercise31_02Server.
(a)
(b)
F IGURE 31.18
The client in (a) sends the weight and height of a person to the server and receives the BMI from the
server in (b).
Sections 31.3 and 31.4
*31.3 ( Loan server for multiple clients ) Revise Programming Exercise 31.1 to write a
server for multiple clients.
Section 31.5
31.4
( Count clients ) Write a server that tracks the number of the clients connected to
the server. When a new connection is established, the count is incremented by
1. The count is stored using a random-access file. Write a client program that
 
Search WWH ::




Custom Search