Java Reference
In-Depth Information
Write a program to evaluate postfix expressions. Pass the expression as a
command-line argument in one string.
***20.15
( Game: the 24-point card game ) Improve Programming Exercise 20.13
to enable the computer to display the expression if one exists, as shown in
Figure  20.20. Otherwise, report that the expression does not exist. Place the
label for verification result at the bottom of UI. The expression must use all
four cards and evaluates to 24.
F IGURE 20.20
The program can automatically find a solution if one exists.
**20.16
( Convert infix to postfix ) Write a method that converts an infix expression into
a postfix expression using the following header:
public static String infixToPostfix(String expression)
For example, the method should convert the infix expression (1 + 2) * 3 to
1 2 + 3 * and 2 * (1 + 3) to 2 1 3 + * .
***20.17
( Game: the 24-point card game ) This exercise is a variation of the 24-point
card game described in Programming Exercise 20.13. Write a program to
check whether there is a 24-point solution for the four specified numbers. The
program lets the user enter four values, each between 1 and 13 , as shown in
Figure 20.21. The user can then click the Solve button to display the solution or
display “No solution” if none exist.
F IGURE 20.21
The user enters four numbers and the program finds a solution.
*20.18
( Directory size ) Listing 20.7, DirectorySize.java, gives a recursive method for
finding a directory size. Rewrite this method without using recursion. Your
 
Search WWH ::




Custom Search