Posts

Showing posts from 2021

Take Input from user in Java

 import java.io.*; // first line step 1 public class DemoInput2 { public void abc(String name,int age) { System.out.println("name "+name+" age "+age); } public void calc() throws IOException , NumberFormatException { BufferedReader brr = new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter no1"); //String n = br.readLine();  // input 1 //String na= n.trim(); //int nn = Integer.parseInt(na); // short way int nn = Integer.parseInt(brr.readLine().trim()); System.out.println("enter no2"); //String n1 = br.readLine(); // input 2 //int nn1 = Integer.parseInt(n1); int nn1 = Integer.parseInt(brr.readLine().trim()); int sum = nn+nn1; System.out.println(sum); } public static void main(String[] args) throws IOException  // step 2 { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println(&q

DemoException java

  public class DemoException { public void calculate(int i,int j) // throws Exception { System.out.println(i+j); try { System.out.println(i/j);  // expect error can come } catch(Exception e) { // e.printStackTrace();  // system print error //System.err.println("my error message");  // user error    // alternate System.out.println("alternate code "+i/1); } finally { System.out.println(i-j);   // always execute  System.out.println(i*j); } } public static void main(String[] args) throws Exception { // TODO Auto-generated method stub DemoException d = new DemoException(); d.calculate(12, 2); } }

ArrayPyramid

  public class ArrayPyramid { public static void main(String[] args) { // TODO Auto-generated method stub String palindrome = "Devendra";         int len = palindrome.length();           System.out.println("length :"+len);         char tempCharArray[]  = new char[len];   // single dimention                  // put original string in an          // array of chars         for (int i = 0; i < len; i++) {     // add values in single dimention..             tempCharArray[i] =                  palindrome.charAt(i);         }          char c[][]=new char[len][len];    // two dimention         for (int row = 0; row < len; row++) {                  for(int col=0;col<=row;col++) { // same no of cols as row no i.e 1st row has 1 col and 2nd row has 2 cols                        // add values in two dimention       c[row][col]=tempCharArray[col]; //System.out.println("c["+(row)+"]["+(col)+"]="+tempCharArray[col]);  System.out.print(

Array In java

  public class ArrayArrange { public static void main(String[] args) { int number[]={55,40,8,65,41}; //declare         for(int i=0;i<number.length;i++)             {                   System.out.println("outer for"+i);          for(int j=i+1;j<number.length;j++)              {                     System.out.println("inner for "+j);      System.out.println(  "if("+number[i]+" > "+number[j]+")");              if(number[i] > number[j])               { System.out.println(" int temp="+number[i]);          int temp=number[i];           System.out.println("temp :"+temp);    System.out.println(number[i]+"="+number[j]);           number[i]=number[j];  // replace value        System.out.println( number[j]+"="+temp);                number[j]=temp;                       } // end of if         }  // end of inner for             }  // end of ou

Core java Selenium Software Testing

import java.io.*; public class Assign1  { public void calc() throws IOException { BufferedReader brr=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter operator"); String o=brr.readLine().trim(); System.out.println("Enter value of a"); // String a=brr.readLine(); int a1=Integer.parseInt(brr.readLine().trim()); System.out.println("Enter value of b"); // String b=brr.readLine(); int b1=Integer.parseInt(brr.readLine().trim()); int res = 0; if(o.equals("+")) { res = a1+b1; } else if(o.equals("-")) { res = a1-b1; } System.out.println(res); } public static void main(String[] args) throws IOException { Assign1 add=new Assign1(); add.calc(); } }

Music Player

import   pygame from   pygame   import   mixer from   tkinter   import  * import   os def   playsong ():      currentsong = playlist . get ( ACTIVE )      print ( currentsong )      mixer . music . load ( currentsong )      songstatus . set ( "Playing" )      mixer . music . play () def   pausesong ():      songstatus . set ( "Paused" )      mixer . music . pause () def   stopsong ():      songstatus . set ( "Stopped" )      mixer . music . stop () def   resumesong ():      songstatus . set ( "Resuming" )      mixer . music . unpause ()     root = Tk () root . title ( 'e-Lalita Music Player' ) mixer . init () songstatus = StringVar () songstatus . set ( "choosing" ) playlist = Listbox ( root , selectmode = SINGLE , bg = "Gray" , fg = "Yellow" , font =( 'Ariel' , 15 ), width = 40 , highlightthickness = 15 , highlightcolor = 'yellow' ,) playlist . grid ( columnspan = 5 ) os . chdir ( r 'c:\s