Java Reference
In-Depth Information
17. A permutation of three objects, a, b, and c, is any arrangement of these
objects in a row. For example, some of the permutations of these objects are
abc, bca, and cab. The number of permutations of three objects is 6. Suppose
that these three objects are strings. Write a program that prompts the user to
enter three strings. The program then outputs the six permutations of those
strings.
18. Write a program that computes the cost of painting and installing carpet in a
room. Assume that the room has one door, two windows, and one book-
shelf. Your program must do the following:
a. Prompts the user to enter, in feet, the length, width, and height of a
room. Read the dimensions of the room.
b. Prompts the user to enter the widths and heights, in feet, of the door,
each window, and the bookshelf. Read these quantities.
c. Prompts the user to enter the cost, per square foot, of painting the
walls. Read these quantities.
d. Prompts the user to enter of cost, per square foot, of installing carpet.
Read these quantities.
e. Outputs the cost of painting the walls and installing the carpet.
19. Write a program that prompts the user to input the amount of rice, in
pounds, in a bag. The program outputs the number of bags needed to store
one metric ton of rice.
20. Cindy uses the services of a brokerage firm to buy and sell stocks. The firm
charges 1.5% service charges on the total amount for each transaction, buy
or sell. When Cindy sells stocks, she would like to know if she gained or
lost on a particular investment. Write a program that allows Cindy to input
the number of shares sold, the purchase price of each share, and the selling
price of each share. The program outputs the amount invested, the total
service charges, amount gained or lost, and the amount received after selling
the stock.
2
Search WWH ::




Custom Search