FirstName_LastName_SerialNumber Clas: The First_Last_SerialNumber class is used by the Home Software Company to validate software serial numbers. A valid software serial number is in the form LLLLL-DDDD-LLLL, where L indicates an alphabetic letter and D indicates a numeric digit. For example, WRXTQ-7786-PGVZ is a valid serial number. Notice that a serial number consists of three groups of characters, delimited by hyphens.
In JAVA
HERE IS SerialNumberTester class:
public class SerialNumberTester
{
public static void main(String[] args)
{
String serial1 = "GHTRJ-8975-AQWR"; // Valid
String serial2 = "GHT7J-8975-AQWR"; // Invalid
String serial3 = "GHTRJ-8J75-AQWR"; // Invalid
String serial4 = "GHTRJ-8975-AQ2R"; // Invalid
// Validate serial1.
First_Last_SerialNumber sn = new First_Last_SerialNumber(serial1);
if (sn.isValid())
System.out.println(serial1 + " is valid.");
else
System.out.println(serial1 + " is invalid.");
// Validate serial2.
sn = new First_Last_SerialNumber(serial2);
if (sn.isValid())
System.out.println(serial2 + " is valid.");
else
System.out.println(serial2 + " is invalid.");
// Validate serial3.
sn = new First_Last_SerialNumber(serial3);
if (sn.isValid())
System.out.println(serial3 + " is valid.");
else
System.out.println(serial3 + " is invalid.");
// Validate serial4.
sn = new First_Last_SerialNumber(serial4);
if (sn.isValid())
System.out.println(serial4 + " is valid.");
else
System.out.println(serial4 + " is invalid.");
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images