class in java

 import java.util.Scanner;

class employe{

    String name;

    int id;

    int salary;

    void display(){

        System.out.println(name+" employe information");

        System.out.println(salary+" salary");

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

    }

}

public class Main{

public static void main(String[]args){

Scanner sc=new Scanner(System.in);

System.out.println("employe e1 details");

 employe e1=new employe();

 e1.name=sc.nextLine();

 e1.id=sc.nextInt();

 e1.salary=sc.nextInt();

 sc.nextLine();

 System.out.println("employe e2 details");

 employe e2=new employe();

 e2.name=sc.nextLine();

 e2.id=sc.nextInt();

 e2.salary=sc.nextInt();

 e1.display();

 e2.display();

 sc.close();

}}

MULTIPLICATION OF TABLE UP TO GIVEN NUMBER

import java.util.Scanner;

public class Main{

public static void main(String[]args){

Scanner sc=new Scanner(System.in);

int n=sc.nextInt();

for (int j=1;j<=n;j++){

for(int i=1;i<=10;i++){

    System.out.println(j+"x"+i+"="+(j*i));

}

}

}

}

GENERAL PRINTING PATTERN


public class Main{

public static void main(String[]args){

for (int row=1;row<=5;row++){

for(int col=1;col<=5;col++){

    System.out.print("*");

}

System.out.println();

}}}

PRINTING PATTERN SPACE

import java.util.Scanner;

public class Main{

public static void main(String[]args){

    Scanner sc=new Scanner(System.in);

    System.out.println("Enter rows");

    int n=sc.nextInt();

     System.out.println("Enter cols");

    int m=sc.nextInt();

for (int row=1;row<=n;row++){

for(int space=1;space<=n-row;space++){

    System.out.print(" ");

}

for(int col=1;col<=row;col++){

    System.out.print("*");

}

System.out.println();

}

}

}


import java.util.Scanner;

public class Main{

public static void main(String[]args){

    Scanner sc=new Scanner(System.in);

    System.out.println("Enter rows");

    int n=sc.nextInt();

     System.out.println("Enter cols");

    int m=sc.nextInt();

for (int row=1;row<=n;row++){

for(int col=1;col<=m;col++){

    if(row==col||row+col==n+1){

    System.out.print("*");

}else{

    System.out.print(" ");

}

}

System.out.println();

}

}

}

Comments

Popular posts from this blog

COCO FARMING MACHINE