Question: java program Question 26 The method getMNumber takes a string as a parameter that represents a student's M number. The string always starts with the

 java program Question 26 The method getMNumber takes a string as

java program

Question 26 The method getMNumber takes a string as a parameter that represents a student's M number. The string always starts with the letter M. and is followed by a number. The following are some examples of valid strings: "M2091 6 points Save 2345". "M20811111" "M20933333", etc. The following is an example of an invalid string: "MXYZ12345". The method returns the number (an integer) follows "M" in the string. If the user provides an incorrect M number, that is, one with non-digits following the M, the method vill print "Invalid String' to the console, using System.out.println), and return the integer 0. For this problem: 1. Implement the getMNumber method 2. Ensure that the message "Invalid String is 3. HINTS Remember that the method charAtt) returns the character at a particular position in a string Q using System.out printin) when an incorrect M number is entered, ie, one with non-digits following the character M haracter isDigit(char thisChar) checks if thisChar is a digit, and Integer parselnt(String intStr) parses a string into an integer Start with the following code: import Jeva.util.Scanner; public clase veilities ( statie scanner #c-new Scanner {System.in) ; public static void main (Strina argo) /scudent enters a promp for the user String va aehexcLine System.out,println igerNumber ival)) public acatic int getllunber (String value) // Student completes ?0 the integer fellowing // returned if value has only diguto following the M // and otherwise printe "Invalid String" and recurne b

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!