0% found this document useful (0 votes)
12 views1 page

Code Package Mathematics Code Code

Uploaded by

zemsetanishka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Code Package Mathematics Code Code

Uploaded by

zemsetanishka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

*; //calculate the sum of digits for a given char //SortData that contains the method asec()
public class Count array consisting of the digits 0 to 9 and desc().
{ Code:
public static void stringCount(String x) import java.util.*; class SortData
{ class SumofDigits {
char[] ch=x.toCharArray(); { int n,temp,i,j;
int letter=0,space=0,num=0,other=0; public static void main(String arg[]) public void vector
desc(int num[])
//package
for(int in java class.
i=0;i<x.length();i++) //add{ two matrices and print the resultant //implement
matrix. {
Code:
{ long n,s;
Code: Code: for(i=0;i<num.length;i++)
import java.util.Vector;
if(Character.isLetter(ch[i])) Scanner sc=new Scanner(System.in);
Package
{ mathematics classSystem.out.println("Enter
MatrixAdd a number "); {
public class VectorDemo
package mathematics;
letter++; { n=sc.nextLong(); { for(j=i;j<num.length;j++)
} class Mathmethods s=sum(n); {
public public static void main(String args[]) public static void main(String args[])
if(num[i]<num[j])
{ else if(Character.isDigit(ch[i])) { System.out.println("Sum of digits of a {
{ static float sqr(float n) number is "+s); {
public int a[] []={{1,2},{3,4}}; Vector<String>v=new Vector<String>();
num++; } temp=num[i];
{ } int b[] []={{5,6},{7,8}};
static int sum(long num)
System.out.println("is
num[i]=num[j]; vector
return
elsen*n;
if(Character.isSpaceChar(ch[i])) int c[]
{ []=new int[2] [2]; empty?"+v.isEmpty());
num[j]=temp;
} { int i,j;
int sum=0; v.add("Red");
}
public static int sqr(int n)
space++; System.out.println("Matrix
while(num!=0) A"); v.add("Green");
}
{ } for(i=0;i<2;i++)
{ v.add("Blue");
}
elsen*n;
return { sum+=num%10; System.out.println(v);
System.out.println("Descending order");
} { num/=10;
for(j=0;j<2;j++) v.add(2,"Yellow");
for(i=0;i<num.length;i++)
other++;
public static double sqr(double n) { } System.out.println(v);
{
{ } return sum;
System.out.print(a[i] [j]+" "); System.out.println("elements
System.out.println(num[i]+" ");at third
} }
return n*n; } } }
position:"+v.get(3));
System.out.println("letter:"+letter);
} System.out.println("number:"+num); System.out.println(); }
System.out.println("first
public static long sqr(long n) }
System.out.println("Spaces:"+space); public void asec(int num1[])
element:"+v.firstElement());
{ System.out.println("Others:"+other); System.out.println("Matrix B"); {
System.out.println("last
return
} n*n; for(i=0;i<2;i++) for(i=0;i<num1.length;i++)
element:"+v.lastElement());
} public static void main(String args[])
{ {
System.out.println("IsTheVectorEmpty?
} { for(j=0;j<2;j++) for(j=i;j<num1.length;j++)
"+v.isEmpty());
SQRScanner sc=new Scanner(System.in); { //to implement multiple inheritance } {
} if(num1[i]>num1[j])
System.out.println(“enter any string”);Code:
import java.io.*; System.out.print(b[i] [j]+" ");
String test=sc.nextLine(); interface S {
import mathematics.Mathmethods;
stringCount(test); } {
temp=num1[i];
class} SQR System.out.println();
public void show(); num1[i]=num1[j];
{ } } } num1[j]=temp;
public static void main(String args[]) System.out.println("Mateix
interface T extends S A+B"); //Find
} the smallest and largest element
{ for(i=0;i<2;i++)
{ from
} the array
int a; { public void display(); Code:
}
a=2;
//implementation of abstract class. }
for(j=0;j<2;j++) class ArrayDemo
System.out.println("\n Ascending Order");
Mathmethods
Code: mm=new Mathmethods(); { class MultipleDemo implements T { for(i=0;i<num1.length;i++)
public class Pract4B {
int b=mm.sqr(a); c[i][j]=a[i][j]+b[i][j];
public void show()
public
{ static void main(String args[])
{
System.out.println("square is"+b); System.out.print(c[i][j]+" "); { System.out.println(num1[i]+" ");
{
} public Pract4B() } System.out.println("from interface S"); int}num[]=new int[]{15,25,13,7,18};
{
} System.out.println(" Hello!Welcome System.out.println();
} int}s=num[0];
to SYIT"); } public void display() int}g=num[0];
} } { intpublic
i; class AsenDesc
public void finalize() } System.out.println("from interface T"); {
for(i=0;i<num.length;i++)
{ } { public static void main(String args[])
System.out.println("Destroyed"); public static void main(String args[]) {
System.out.println(num[i]);
{
}
MultipleDemo md=new MultipleDemo(); } SortData s1=new SortData();
public static void main(String args[]) int ar[]=new int[]{15,16,12,13,6};
for(i=1;i<num.length;i++)
md.show();
{
md.display(); { s1.desc(ar);
Pract4B b=new Pract4B(); s1.asec(ar);
b=null; } if(num[i]>g)
}
System.gc(); } g=num[i];
}
} else if(num[i]<s)
} s=num[i];
}
System.out.println("largest number in
array:"+g);
System.out.println("smallest number in
array:"+s);
}
}

You might also like