Write a Complete program for the following specification: The SerialNumber class
ID: 3651830 • Letter: W
Question
Write a Complete program for the following specification:The SerialNumber class takes a software serial number in
the form of LLLLL-DDDD-LLLL where each L is a letter
and each D is a digit. The serial number has three groups
of characters, separated by hyphens. The class extracts
the three groups of characters and validates them.
Example:
String serial1= "GHTRJ-8975-AQWR"; // Valid
String serial2 = "GHT7J-8975-AQWR"; // Invalid
String serial3 = "GHTRJ-8J75-AQWR"; // Invalid
String serial4 = "GHTRJ-8975-AQ2R"; // Invalid
Explanation / Answer
import java.util.Scanner; public class SerialNumber { static String serialNo; public static void main(String[] args) { int flag=0; System.out.println("Enter the serial no."); Scanner input=new Scanner(System.in); serialNo=input.next(); for(int i=0;i17){ flag=1; } else { if(i>=0 && i=6 && i=12 && iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.