❌

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

Patterns – Printing Name

By: Sugirtha
20 October 2024 at 15:03
public class PatternMyName {
	//  MY NAME - IN PATTERN PRINTING

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		PatternMyName pattern = new PatternMyName();
		int n=9;
		pattern.printLtr("S",n);
		pattern.printLtr("U",n);
		pattern.printLtr("G",n);
		pattern.printLtr("I",n);
		pattern.printLtr("R",n);
		pattern.printLtr("T",n);
		pattern.printLtr("H",n);
		pattern.printLtr("A",n);
	}
	private void printLtr(String ltr,int n) {
		int m=n/2 +1;
		switch(ltr) {
			case "S":
				for (int r=1; r<=n; r++) {
					for (int c=1; c<=n; c++) {
						if (r==1 || r==n || r==m || (c==1 && r<m) || (c==9 && r>m)) {
							if ((c==1 && r==1) || (r==n && c==n) || (r==m && (c==1 || c==n))) System.out.print("  ");
							else System.out.print(" *");
						}
						else System.out.print("  ");
					}
					System.out.println();
				}
				System.out.println();
				break;
				
			case "U":
				for (int r=1; r<=n; r++) {
					for (int c=1; c<=n; c++) {
						if ((c==1 && r<n)|| (c>1 && c<n && r==n) || (r<n && c==n))
								System.out.print(" *");
						else System.out.print("  ");
					}
					System.out.println();
				}
				System.out.println();
				break;
			
			case "G":
				for (int r=1; r<=n; r++) {
					for (int c=1; c<=n; c++) {
						if ((r==1 && c!=1) || (c==1 && r!=1 && r!=n) || (r==n && c!=1 && c!=n) || (c==n && r>=m && r!=n) || (r==m && c>m)) System.out.print(" *");
						else System.out.print("  ");
					}
					System.out.println();
				}
				System.out.println();
				break;

			case "I":
				for (int r=1; r<=n; r++) {
					for (int c=1; c<=n; c++) {
						if ( c==m || r==1 || r==n) System.out.print(" *");
						else System.out.print("  ");
					}
					System.out.println();
				}
				System.out.println();
				break;
				
			case "R":
				for (int r=1; r<=n; r++) {
					for (int c=1; c<=n; c++) {
						if ( (c==1 && r!=1) || (r==1 && c!=n && c!=1) || (c==n && r<m && r!=1) || (r==m && c!=n) || (r>m && c==m+(r-m))) System.out.print(" *");
						else System.out.print("  ");
					}
					System.out.println();
				}
				System.out.println();
				break;
				
			case "T":
				for (int r=1; r<=n; r++) {
					for (int c=1; c<=n; c++) {
						if ( c==m || r==1 ) System.out.print(" *");
						else System.out.print("  ");
					}
					System.out.println();
				}
				System.out.println();
				break;
				
			case "H":
				for (int r=1; r<=n; r++) {
					for (int c=1; c<=n; c++) {
						if ( c==1 || c==n || r==m) System.out.print(" *");
						else System.out.print("  ");
					}
					System.out.println();
				}
				System.out.println();
				break;
			
			case "A":
				for (int r=1; r<=n; r++) {
					for (int c=1; c<=n; c++) {
						if ( (r<=m && (c==m-r+1 || c==m+r-1)) || r==m || (r>m && (c==1 || c==n))) System.out.print(" *");
						else System.out.print("  ");
					}
					System.out.println();
				}
				System.out.println();
				break;

		}
	}
}

OUTPUT:

Task-Password Validation

By: Sugirtha
9 October 2024 at 00:59

Code: TBD

<html>
    <head>
        <title> Password Validation </title>
        <style>
            body {
                background-color:black;
                color:green;
            }
            h1 {
                text-align:center;
                text-decoration:underline;
            }
           .inputTxt{
                color:black;
                background-color:lightgrey;
                border:green 2px solid;
                padding-left:10px;
                width:170px;
                height:24px;
                }
            .lbl {
                 padding:25px;
                 font-weight:bold;
                   
                }
            
            .button {
                background-color:lightgreen;
                color: black;
                border:2px solid green;
                border-radius:15px;
                font-size: 15px;
                vertical-align:9px;
                font-family:"sans-serief";
                font-variant:small-caps;
                font-weight:bold;
                width:170px;
                height:30px;
                text-align:center;
            }
            
        </style>
    </head>
    
    <body>
        <h1 > Password Validation </h1>
            <div align="center">
                <br>
                <form id="frmPw">
                    <table align="center">
                    <tr> 
                        <td> <label for = "idPw" class="lbl"> Password</label> </td>
                        <td> <input type="Password" name="namPw" id="idPw" class="inputTxt" placeholder="Pls enter the Password" minlength=8 maxlength=12>  </td>
                    </tr>
                    </table>
                <br><br>
                <input type="button" value="CLEAR" class="button" onclick="doClear()">&nbsp;&nbsp;
                <input type="submit" value="SUBMIT" class="button" onclick="validatePw()">
                </form>
            </div>
    </body>

    <script>
        function validatePw() {
            const pw = document.getElementById("idPw").value;
            var msg="";
            if (pw.length>12) msg += "Max 12 characters.  Limit exceeded....";
            else if (pw.length<8) msg += "Min 8 characters needed...";
            var containsNumbers = /\d/.test(pw); //TBD
            if (!containsNumbers) msg += "Atleast one digit expected    ";
            var containsUcaseAlphabet = /[A-Z]/.test(pw);  
            if (!containsUcaseAlphabet) msg+="Atleast one Upper Case Alphabet expected  ";
            var containsSpecial = /[!@#$%^&*]/.test(pw); 
            if (!containsSpecial) msg+="Atleast one Special Character expected";             
            if (msg  !== null && msg!='')  //TBD
            {
                alert(msg);
                return false;
            }
            else 
            {
                alert("Password Validation passed successfully...");
                return true;
            }
        }

        function doClear() {
            document.getElementById("frmPw").reset();      
        }
    </script>
</hmtl>

Output:

❌
❌