Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a complete Java application that reads a file with erroneous integer value

ID: 3637273 • Letter: W

Question

Write a complete Java application that reads a file with erroneous integer values, filters the faulty inputs and outputs the rest sorted. The rules that you must follow is given below:
? Input file name will be given as a command line argument. However, if it is not
provided from the command line, your program should ask the user to enter the input
file name until it gets a valid file name.
? The input file contains integer values one per line, some of them are invalid. Read
each line and extract integer values. Your program should handle the exceptions that
may arise and be able to read every valid integer value until the end of file.
? You are not given the number of integers that the input file contains. That is your
program detects the end-of-file.
? Write a separate class IntSort. IntSort has a constructor which takes an unsorted
integer array as a parameter, sorts the integers in the given array and stores the sorted
array as a class attribute. IntSort has another method which returns the integer array
containing the sorted integers. You may use any sorting algorithm.
As the second part of your homework, write another Java application that handles the floating point numbers according to the above given rules.

Explanation / Answer

java.lang.Object java.lang.Number java.lang.Float All Implemented Interfaces: Comparable, Serializable public final class Float extends Number implements Comparable The Float class wraps a value of primitive type float in an object. An object of type Float contains a single field whose type is float. In addition, this class provides several methods for converting a float to a String and a String to a float, as well as other constants and methods useful when dealing with a float. Since: JDK1.0 See Also: Serialized Form Field Summary static float MAX_VALUE A constant holding the largest positive finite value of type float, (2-2-23)·2127. static float MIN_VALUE A constant holding the smallest positive nonzero value of type float, 2-149. static float NaN A constant holding a Not-a-Number (NaN) value of type float. static float NEGATIVE_INFINITY A constant holding the negative infinity of type float. static float POSITIVE_INFINITY A constant holding the positive infinity of type float. static Class TYPE The Class instance representing the primitive type float. Constructor Summary Float(double value) Constructs a newly allocated Float object that represents the argument converted to type float. Float(float value) Constructs a newly allocated Float object that represents the primitive float argument. Float(String s) Constructs a newly allocated Float object that represents the floating-point value of type float represented by the string. Method Summary byte byteValue() Returns the value of this Float as a byte (by casting to a byte). static int compare(float f1, float f2) Compares the two specified float values. int compareTo(Float anotherFloat) Compares two Float objects numerically. int compareTo(Object o) Compares this Float object to another object. double doubleValue() Returns the double value of this Float object. boolean equals(Object obj) Compares this object against the specified object. static int floatToIntBits(float value) Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout. static int floatToRawIntBits(float value) Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "single format" bit layout, preserving Not-a-Number (NaN) values. float floatValue() Returns the float value of this Float object. int hashCode() Returns a hash code for this Float object. static float intBitsToFloat(int bits) Returns the float value corresponding to a given bit represention. int intValue() Returns the value of this Float as an int (by casting to type int). boolean isInfinite() Returns true if this Float value is infinitely large in magnitude, false otherwise. static boolean isInfinite(float v) Returns true if the specified number is infinitely large in magnitude, false otherwise. boolean isNaN() Returns true if this Float value is a Not-a-Number (NaN), false otherwise. static boolean isNaN(float v) Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise. long longValue() Returns value of this Float as a long (by casting to type long). static float parseFloat(String s) Returns a new float initialized to the value represented by the specified String, as performed by the valueOf method of class Float. short shortValue() Returns the value of this Float as a short (by casting to a short). String toString() Returns a string representation of this Float object. static String toString(float f) Returns a string representation of the float argument. static Float valueOf(String s) Returns a Float object holding the float value represented by the argument string s. Methods inherited from class java.lang.Object clone, finalize, getClass, notify, notifyAll, wait, wait, wait Field Detail POSITIVE_INFINITY public static final float POSITIVE_INFINITY A constant holding the positive infinity of type float. It is equal to the value returned by Float.intBitsToFloat(0x7f800000). See Also: Constant Field Values NEGATIVE_INFINITY public static final float NEGATIVE_INFINITY A constant holding the negative infinity of type float. It is equal to the value returned by Float.intBitsToFloat(0xff800000). See Also: Constant Field Values NaN public static final float NaN A constant holding a Not-a-Number (NaN) value of type float. It is equivalent to the value returned by Float.intBitsToFloat(0x7fc00000). See Also: Constant Field Values MAX_VALUE public static final float MAX_VALUE A constant holding the largest positive finite value of type float, (2-2-23)·2127. It is equal to the value returned by Float.intBitsToFloat(0x7f7fffff). See Also: Constant Field Values MIN_VALUE public static final float MIN_VALUE A constant holding the smallest positive nonzero value of type float, 2-149. It is equal to the value returned by Float.intBitsToFloat(0x1). See Also: Constant Field Values TYPE public static final Class TYPE The Class instance representing the primitive type float. Since: JDK1.1 Constructor Detail Float public Float(float value) Constructs a newly allocated Float object that represents the primitive float argument. Parameters: value - the value to be represented by the Float. Float public Float(double value) Constructs a newly allocated Float object that represents the argument converted to type float. Parameters: value - the value to be represented by the Float. Float public Float(String s) throws NumberFormatException Constructs a newly allocated Float object that represents the floating-point value of type float represented by the string. The string is converted to a float value as if by the valueOf method. Parameters: s - a string to be converted to a Float. Throws: NumberFormatException - if the string does not contain a parsable number. See Also: valueOf(java.lang.String)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote