Question: Assignment Create the public class Module 1 with the following data fields and methods: 1) Data fields: 1. an object of type Scanner named sc

 Assignment Create the public class Module 1 with the following data
fields and methods: 1) Data fields: 1. an object of type Scanner

Assignment Create the public class Module 1 with the following data fields and methods: 1) Data fields: 1. an object of type Scanner named sc (you can import this from Java.util.Scanner) b. an int named i ca double named d 2) Methods: .. a method named squareRoot that returns an int, accepts an int parameter named number, and returns (as an int) the square root of number, i.e., the value (int)(number) b a method named cubeRoot that returns an int, accepts an int parameter named number, and returns (as an int) the cube root of number, i.e., the value (int)(number) c. a method named squareRoot that returns a double, accepts a double parameter named number, and returns the square root of number da method named cubeRoot that returns a double, accepts a double parameter named number, and returns the cube root of number ca constructor method that creates Module 1's Scanner object (SC) using the System.in argument to read console input 1.A main method (i.e., with the header public static void main(Stringl args)) that, in order: Creates a new Module 1 object named m by calling Module 1's constructor method . Prints the message "beginning application to the console . Prints a message to the console (use System.out.println() asking the user to enter an integer . Reads the user input using the Scanner object's nextDouble() method and assigns the value returned by nextDouble to Module 1's d field, then assigns to i the value of d typecast to an int Calls m's methods (2a & 2b) with i as the argument: 12a: print "int square root:" and the value returned by m.squareRoot(m.i) to the console 22b: print "int cube root:" and the value returned by m.cubeRoot(i) to the console . Calls m's methods (2c & 2d) with d as the argument: 12c: print "double square root:" and the value returned by m.square Root(m.d) to the console 2.2d: print "double cube root: " and the value returned by m.cubeRoot(m.d) to the console . Prints the message "ending application to the console Additional Constraints . Other than Module 1's main method, all data fields & methods should be for individual objects, not the entire class. . Use Math.pow() for exponentiation. The Math.pow() method accepts two doubles, the first as the base and the second as the exponent. For the method calls 2a - 2d, be sure that the exponent is a double: in Java, 2 is not the same as 0.5. Comments should be provided at the start of the file (i.e., above the class definition) giving the class author's name and the date the program was finished. Sample program console output: Note that, due to approximation of floating point numbers in the Math.pow() method, the cube root calculations are off (should be 4 or 4.0 for 64 and 9 or 9.0 for 729). This is acceptable for the assignment starting application double souare root: 8.a double cube root: 3.9999999999999996 ending application starting application please enter an integer int cube root: double square root: 27.0 Co rooti 8.999999999999998 ending application

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!