Answered You can hire a professional tutor to get the answer.
Creating a class named Module3 containing the following data members and methods (note that all data members and methods are for objects unless
Creating a class named Module3 containing the following data members and methods (note that all data members and methods are for objects unless specified as being for the entire class)
- 1)Data members:
- a.A Scanner object named reader (your class will need to import the Scanner class)
- b.Two int variables named format and pointIndex
- c.A double variable named inputDouble
- d.A String object named outputString, initialized to "" (an empty String)
- 2)Methods:
- a.A main method that, in order:
- •Creates a new Module3 object
- •Prints the text "starting application" to the console
- •Calls method b) with the argument "Please enter a floating point number" and assigns its returned double value to inputDouble
- •Calls method c) with the argument "How many decimal places to display?" and assigns its returned int value to format
- •Calls method d) with the argument format and the String "The formatted number is: "
- •Prints the text "ending application" to the console
- b.A method named getInput that accepts a String parameter, prints the parameter String to the console, accepts a user-entered double via the console (use Scanner.nextDouble()), prints "Thank you" to the console, and returns the user-entered double value.
- c.A method named getFormat that accepts a String parameter, prints the parameter String to the console, accepts a user-entered int via the console (use Scanner.nextInt()), prints "Thank you" to the console, and returns the user-entered int value. For error-checking, if the user enters a negative value, the program should print the message "invalid input. halting." to the console, then exit the program by calling System.exit(1);
- d.A method named convert that:
- •Accepts two parameters: a String parameter and an int named places
- •Assigns outputString the text "" + inputDouble
- •Assigns to pointIndex the index of the decimal point (use String.indexOf())
- •If places is greater than 0, places should be incremented by one (to account for the decimal point's extra character)
- •Extracts the substring from outputString starting from index zero to the specified number of decimal places (i.e., pointIndex + places)
- •Displays via the console the parameter String concatenated with the substring from the previous bullet point