Monday 23 April 2018

STRING EQUALS() METHOD WITH LOGIN FORM


package javaapplication38;

import java.util.Scanner;


public class JavaApplication38 {


    public static void main(String[] args)
    {
       int attemp=3;
        String userid="salman",password="xyz123";
        Scanner sc=new Scanner(System.in);
        String uid,pwd;
       
        System.out.println("Enter you email id to use this software...........");
        uid=sc.next();
        if (uid.equalsIgnoreCase(userid)==true)
        {
            while(attemp>=0)
            {
              System.out.println("Enter your password :");
                pwd=sc.next();
                if (pwd.equals(password))
                {
                   
                    System.out.println("You are successfully login......."); 
                    break;
                }
                else 
                {
              System.out.println("Invalid Password.....\nyou have "+attemp+" left ");
              attemp--;
                }
            }
           
           
           
        }
        else
        {
            System.out.println("Invalid id.....\nyou have "+attemp+" left ");
         
        }
       
    }
   
}

Friday 20 April 2018

HashSet code


package javaapplication37;

import java.util.HashSet;
import java.util.Scanner;

class employee
{
int id,salary;
String name;

public employee(String name,int id,int salary)
{

    this.id=id;
    this.name=name;
    this.salary=salary;
}



}





public class JavaApplication37

{

   
    public static void main(String[] args)
    {
        char c='y',c2='y';
        String n;
        int id=10231,salary,op;
        Scanner sc=new Scanner(System.in);
        HashSet<employee> li=new HashSet<employee>();
       
       
        while(c!='n' && c!='N')
        {
            System.out.println("Enter the Name of Employee ");
            n=sc.next();
            System.out.println("Enter the Salary: ");
            salary=sc.nextInt();
            li.add(new employee(n,id,salary));
            id++;
            System.out.println("Data Successfully inserted......\nDo you want to continue (y/n) ? ");
           c= sc.next().charAt(0);
           
        }
       
       
        while(c2!='n' && c2!='N' )
       {
     
        System.out.println("Enter the no to select any operation:");
        System.out.println("Press 1 to Delete a Record");
        System.out.println("Press 2 to view all Record");
        System.out.println("Press 3 to Delete all Record");
        System.out.println("Press 4 to Add new Record");
       
        op=sc.nextInt();
       
        switch(op)
        {
         case 1:
                 System.out.println("Enter the id of Employee:");
                  id =sc.nextInt();
                 li.remove(id-1);
                System.out.println("Record deleted.....");
                break;
               
              case 2:
                boolean b=li.isEmpty();
                  if (b==true)
                  {
                      System.out.println("There is no record in the list........");   
                  }
                  else  {
                  for(employee obj:li)
                  {
                      System.out.println("Student id: "+obj.id);
                      System.out.println("name of sutdent is : "+obj.name);
                      System.out.println("Marks of sutdent is : "+obj.salary);
                      System.out.println("----------------------------------------");
                     
                 
                  }
                 
                  }
                 
                break;
               
             case 3:
                 li.removeAll(li);
                 System.out.println("All records deleted.......");
                break;
               
               
             case 4:
                 c='y';
                   while(c!='n' && c!='N')
        {
            System.out.println("Enter the Name of Employee ");
            n=sc.next();
            System.out.println("Enter the Salary: ");
            salary=sc.nextInt();
            li.add(new employee(n,id,salary));
            id++;
            System.out.println("Data Successfully inserted......\nDo you want to continue (y/n) ? ");
           c= sc.next().charAt(0);
           
        }
               
               
                 break;
               
              default:
                  break;
     
       
        }
       
        }
       
       
       
        for(employee e:li)
        {
            System.out.println("Id is: "+e.id);
            System.out.println("Name is: "+e.name);
            System.out.println("Salary is :"+e.salary);
        }
     
    }
   
}

Wednesday 4 April 2018

Multiple inheritance in java using interface







package javaapplication26;



interface employee

{

   

void printemployeedetails(String n,int id);





}



interface teacher

{



void printteacherdetails(String batch,int id);



}



class teamleader implements employee,teacher

{

   

public void printemployeedetails(String n,int id)

{

    System.out.println("Name of Employee is "+n);

    System.out.println("Employee id : "+id);

}



public void printteacherdetails(String batch,int id)

{

 System.out.println("Batch code: "+batch);

    System.out.println("Teacher id : "+id);

}





public void showleaderdetials(String n)

{

    System.out.println("Team leader name is "+n);

}



}









public class JavaApplication26



{



 

    public static void main(String[] args)

    {

      teamleader tl=new teamleader();

      tl.printemployeedetails("salman", 2245);

      tl.printteacherdetails("1708C1", 4332);

      tl.showleaderdetials("salman");

    }

   

}


Multiple inheritance in java using interface







package javaapplication26;



interface employee

{

   

void printemployeedetails(String n,int id);





}



interface teacher

{



void printteacherdetails(String batch,int id);



}



class teamleader implements employee,teacher

{

   

public void printemployeedetails(String n,int id)

{

    System.out.println("Name of Employee is "+n);

    System.out.println("Employee id : "+id);

}



public void printteacherdetails(String batch,int id)

{

 System.out.println("Batch code: "+batch);

    System.out.println("Teacher id : "+id);

}





public void showleaderdetials(String n)

{

    System.out.println("Team leader name is "+n);

}



}









public class JavaApplication26



{



 

    public static void main(String[] args)

    {

      teamleader tl=new teamleader();

      tl.printemployeedetails("salman", 2245);

      tl.printteacherdetails("1708C1", 4332);

      tl.showleaderdetials("salman");

    }

   

}


Monday 2 April 2018

interfaces in java (Abstraction in OOP)







package javaapplication25;





interface shape

{



    void area();

 

}

class square implements shape

{

float s;

 public void area()

 {

     System.out.println("area of square is "+s*s);

 }





}



public class JavaApplication25 {



   

    public static void main(String[] args)

    {

       square s= new square();

        s.s=10;

       s.area();

   

       

    }

   

}


Abstraction in java (Object Oriented Programming pillar)







package javaapplication24;



abstract class shape

{



public abstract void printarea();



}

class triangle extends shape

{

   float b,h;

public  void printarea()

{

    System.out.println("area of triangle is "+0.5*b*h);

}

}



class square extends shape

{

    float s;

public  void printarea()

{

    System.out.println("area of triangle is "+s*s);

}



}







public class JavaApplication24 {



 

    public static void main(String[] args)

    {

        triangle t=new triangle();

        t.b=5;

        t.h=10;

        t.printarea();

   

        square s=new square();

        s.s=2.5f;

        s.printarea();

   

    }

   

}


Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...