Question: Please write the Java Code that will apply to the program Java Eclipse. . . b. . . Assignment Create the public class Module2 with
Please write the Java Code that will apply to the program Java Eclipse.
. . b. . . Assignment Create the public class Module2 with the following data fields and methods: 1) Data fields a an object of type Scanner named sc (you can import this from Java.util.Scanner) b. four Strings: named question, answer, input1, and input2 2) Methods: a. an object method named formatCheck that accepts as parameters a String text and an int code: if code is one o returns true if the parameter String begins with a capital letter and ends with "?" o returns false otherwise if code is two: o returns true if the parameter String begins with a capital letter and ends with a period o returns false otherwise if code is any other value, retums false a constructor method that: creates Module2's Scanner object (sc) using the System.in argument to read console input creates question, answer, input1, and input2 as empty (zero length) Strings c. A main method (i.e., with the header public static void main(String[ args)) that, in order. Creates a new Module2 object named m by calling Module2's constructor method Prints the message 'beginning application to the console Prints a message asking the user to enter question text, reads the input using (m's] Scanner's nextLine() method, and sends it and the code value 1 to formatCheck o If formatCheck returns true assigns it to input1 If formatCheck returns false, print "bad question format" to the console and exits the main method with a retum statement Prints another message asking the user to enter question text, reads the input using (m's] Scanner's nextLine() method, and sends it and the code value 2 to formatCheck o If formatCheck returns true assigns it to input2 o if formatCheck returns false, print "bad answer formatl" to the console and exits the main method with a return statement Prints a message indicating that the question & answer pair was accepted and displays with appropriate labels the question & answer text, e.g: O Q8A validated! o Question: (question text] o Answer (answer text] Prints the message "ending application to the console Additional Constraints Other than Module2's main0 method, all data fields & methods should be for individual objects, not the entire class Use System.out.println() for print operations Comments should be provided at the start of the file (.e, above the class definition) giving the class author's name and the date the program was finished
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
