Nested If Statement, Logical Operators, Background & Forground Colors
Write an applet which will accept three floats at the keyboard. The first float must be smaller than
than the second. Have your applet check to see if the third float is to the left or right of the first two floats.
If it is neither, state that it satisfies the interval made up by the first and second float. For example,
- if your three numbers are 2.5, 8.5, and -3.5, then have your applet output :
-3.5 is to the left of the interval
2.5 <= x <= 8.5
- if your three numbers are -2.5, 17.5, and 17.5, then have your applet output :
17.5 satisfies the interval
-2.5 <= x <= 17.5
- if your three numbers are 40.55, 41, and 42, then have your applet output :
42.0 is the the right of the interval
40.55 <= x <= 41.0
- Document your applet. Include your Name, Date, Project#, and a
description of the project.
- Input the data with the TextField class
- Use a nested if statement.
- Use logical operators.
- Allow all data input to be of type Float.
- In the init section, use the setBackground & setForground methods to select appropriate input & output colors.
Here are some choices for colors : black, blue, cyan, darkGray, gray, green, lightGray, magenta,
orange, pink, red, white, and yellow. Below are examples of the methods used in an applet :
- Activate the output with the Button class.
- Output your result with the TextArea class and setText method.
Sample Output for Project35