Posts

ONE TO ONE CHAT APP

//Code for Friend With Server import java.net.*; import java.io.*; import java.util.Scanner; class clientUnit extends Thread{     PrintWriter out=null;     BufferedReader in=null;     String keyboardinput;     Socket conn=null;     String me="Roshan";     String NAME;     public clientUnit(Socket conn){         try{             this.conn=conn;             this.out = new PrintWriter(conn.getOutputStream(),true);             this.in=new BufferedReader(new InputStreamReader(conn.getInputStream()));         }         catch (IOException ioe){             System.err.println("couldn't communicate with client");         }     }     public void run(){         try{       ...

Coloring of graph

 from random import randint #todo #chromatic number #currently supporting in max 4 color graph n=input("Enter Your vertex seprated by space:").split() vac={} for vertex in n: c=input(f"{vertex} is connected to? give value seprated by space:") vac[vertex]=c.split() CV=[] CG={} first=True for vertex in n: colors=["RED","GREEN","BLUE","YELLOW"] if first==True: first=False RC=colors[randint(0,len(colors)-1)] CG[vertex]=RC CV.append(vertex) continue temp2=vac[vertex] for conn in temp2: if conn in CG: CP=CG[conn] CI=colors.index(CP) colors.pop(CI) CG[vertex]=colors[randint(0,len(colors)-1)] CV.append(vertex) print(CG)

Java prac 2

  import java.util.*; class Main  { public static void main (String[] args) throws java.lang.Exception {     Scanner scan=new Scanner(System.in);     System.out.println("Enter The Number of Rows:");     int n=scan.nextInt();     System.out.println("Enter the number of Cols:");     int m=scan.nextInt();     int[][] array=new int[n][m];     for(int i=0;i<n;i++){       System.out.println("Give The Values of row "+(i+1)+":");       for(int j=0;j<m;j++){       System.out.println("Give The Value of col "+(j+1)+":");       array[i][j]=scan.nextInt();       }     }     System.out.println("Array is Having ");     for(int i=0;i<n;i++){       System.out.println();       for(int j=0;j<m;j++){         System.out.print(array[i][j]+" ");   ...

NumToWord

 #@roshanb79 def convToWord(num): sflw=[] lastc='' uth="" for i in reversed(num): if len(sflw)==0: #checking is list is empty sflw.append(numwords1[i]) uth+="unit:"+i elif len(sflw)==1: uth+=",tens:"+i if i=="0": sflw.append("") elif lastc=="0": sflw[0]="" sflw.append(numwords3[i]) elif i=="1": sflw.pop(0) sflw.append(numwords2[lastc]) else: sflw.append(numwords3[i]) elif len(sflw)==2: uth+=",hundred:"+i if i=="0": sflw.append("") else: if sflw[0]=="" and sflw[1]=="": sflw.append(numwords1[i]+" Hundred") else: sflw.append(numwords1[i]+" Hundred And ") else: print("Give Number between 0-999") lastc=i finalword="" for word in reversed(sflw): finalword+=word print(finalword) print(...

csvTableToHtml

#roshanb79 def convertToHtml(filename,sep): tbody=[] with open(filename,"r") as f: for line in f.readlines(): tbody.append(line.split(sep)) htmlcode="<table>" for tr in tbody: htmlcode+="<tr>" for td in tr: htmlcode+=f"<td>{td}</td>" htmlcode+="</tr>" htmlcode+="</table>" print(htmlcode) sep=input("Input Your Column Seperator") convertToHtml("table.csv",sep)

JAVA OOP Example #4

class Student{   int rollno;   String name;   int m1;   int m2;   int m3;   int T;   Student(){     this.rollno=04;     this.name="Roshan Bhardwaj";     this.m1=41;     this.m2=43;     this.m3=36;     this.T=m1+m2+m3;   }   Student(int rollno,String name,int m1,int m2,int m3){     this.rollno=rollno;     this.name=name;     this.m1=m1;     this.m2=m2;     this.m3=m3;     this.T=m1+m2+m3;   }   public void printdetails(){     System.out.println("Rollno:"+rollno);     System.out.println("Name:"+name);     System.out.println("Marks1:"+m1);     System.out.println("Marks2:"+m2);     System.out.println("Marks3:"+m3);     System.out.println("Total Marks:"+T);   }    } class Result extends Student{  public void getResult(){   if(T>40){ ...