java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.lang.IllegalArgumentException
java.util.IllegalFormatException
java.util.IllegalFormatPrecisionException
- All Implemented Interfaces:
- Serializable
- See Also:
- Source Code
public String getMessage()
- See Also:
- Throwable
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getPrecision()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public IllegalFormatPrecisionException(int p)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[2013]square with 2 decimal points
By lynn on 2010/09/30 20:39:45 Rate
import java.util.*;
public class p4
{
static Scanner kb = new Scanner ( System.in ) ;
public static void main ( String [ ] args )
{
int x, lowerBound, upperBound;
double square, squareRoot;
System.out.print ( "Please enter a lower bound: " ) ;
lowerBound = kb.nextInt ( ) ;
System.out.print ( "Please enter an upper bound: " ) ;
upperBound = kb.nextInt ( ) ;
if ( lowerBound < upperBound )
for ( x = lowerBound; x < = upperBound; x++ )
{
square = Math.pow ( x,2 ) ;
squareRoot = Math.sqrt ( x ) ;
System.out.printf ( "\n For the value of " + x + " the square is " + "%.2d",square + "and" ) ;
}
else if ( lowerBound > upperBound )
System.out.println ( "no work will be performed." ) ;
}
}