Professional Documents
Culture Documents
catch (Exeption f)
{}
while (n>0)
{
rem=n%10;
rev=rev*10+rem;
n=n/10;
}
System.out.println("\n\t Rev No="+rev);
}
OutPut:
do
{
int cur = iFibOne + iFibTwo;
iFibOne = iFibTwo;
iFibTwo = cur;
System.out.println(cur + ",");
}
while(iFibTwo < 100);
}
}
Output:-
Fibonacci series printing........
0,1,
1,
2,
3,
5,
8,
13,
21,
34,
55,
89,
144,
Name : Vidit Abhilasha
03. Program to compute the sum of the digits of a given integer number.
import java.io.*;
class sum
{
public static void main(String args[])
{
DataInputStream in=new DataInputStream(System.in);
int num=0,sum=0;
try
{
System.out.println("Enter number:");
num=Integer.parseInt(in.readLine());
}
catch (Exception e)
{}
while (num > 0)
{
sum += num % 10;
num /= 10;
}
System.out.println("\n\t Sum of the numbers="+sum);
}
}
OutPut:-
Enter number:
12345
Sum of the number=15
Name : Vidit Abhilasha
class StringOrdering
{
static String name[]={"Minal","Pooja","Shama","Geeta","Meeta","Mohan"};
public static void main(String args[])
{
int size=name.length;
String temp=null;
for(int i=0;i<size;i++)
{
for(int j=i+1;j<size;j++)
{
if((name[j].compareTo(name[i]))<0)
{
temp=name[i];
name[i]=name[j];
name[j]=temp;
}
}
}
for(int i=0;i<size;i++)
{
System.out.println(name[i]);
}
}
}
Output :
Geeta
Meeta
Minal
Mohan
Pooja
Shama
Name : Vidit Abhilasha
System.out.println();
}
int y= array1.length;
System.out.println("Matrix 2 : ");
for(int i = 0; i < y; i++) {
for(int j = 0; j < y-1; j++) {
System.out.print(" "+array1[i][j]);
}
System.out.println();
}
array2[i][j] += array[i][k]*array1[k][j];
Output :
Matrix 1:
567
489
Matrix2:
64
57
11
Output:
Class A
Add=30
Name : Vidit Abhilasha
import java.io.*;
public class pyramid{
public static void main(String args[])
{
int i=1,j;
int num = 1;
while(num<=91)
{
for(j=1; j<=i; j++){
System.out.print (num + " ");
num++;}
i++;
System.out.print("\n");
}
}
}
Output:
1
23
456
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35 36
37 38 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54 55
56 57 58 59 60 61 62 63 64 65 66
Name : Vidit Abhilasha
67 68 69 70 71 72 73 74 75 76 77 78
79 80 81 82 83 84 85 86 87 88 89 90 91
Name : Vidit Abhilasha
class sam
{
public static void main(String args[])
{
int a=1;
for(int j=0;j<5;j++)
{
for(int i=0;i<=j;i++)
{
if(a==0)
{
System.out.print(" "+a++);
}
else
{
System.out.print(" "+a--);
}
}
System.out.print("\n");
}
}
}
Output:-
1
0 1
0 10
1 010
1 0101
Name : Vidit Abhilasha
import java.io.*;
OutPut:
Enter number:
5
1
22
333
4444
55555
Name : Vidit Abhilasha
class student
int roleno;
String name;
float sub1,sub2,sub3=0;
float total()
{
return(sub1+sub2+sub3);
}
float per()
{
return total()/3;
}
}
class methodover
{
public static void main (String[]args)
Name : Vidit Abhilasha
}
}
OutPut:
class staff
{
int code;
String name;
};
}
};
};
class employee
{
public static void main (String[] args)
}
}
OutPut:
*
***
*****
*******
*****
***
*
*/
class Pattern
{
public static void main(String args[])
{
int i,j,k,m=8,m1=0;
for(i=1;i<5;i++)
{
for(k=0;k<m;k++)
{
System.out.print(" ");
}
for(j=1;j<i;j++)
{
System.out.print("*");
}
for(j=1;j<i-1;j++)
{
System.out.print("*");
}
m=m-1;
System.out.println("");
}
for(i=5;i>1;i--)
{
for(k=4;k>m1;k--)
{
Name : Vidit Abhilasha
System.out.print(" ");
}
for(j=i;j>1;j--)
Name : Vidit Abhilasha
{
System.out.print("*");
}
for(j=i-1;j>1;j--)
{
System.out.print("*");
}
m1=m1-1;
System.out.println("");
}
}
}
OutPut:
*
***
*****
*******
*****
***
*
Name : Vidit Abhilasha
Bal=Bal+at;
}
else
{
Bal=Bal-dr;
System.out.println("\n Amount Withdrwn is "+dr);
System.out.println("\n Curent Balance = " +Bal);
}
}
void Display()
{
System.out.println("\n Name Of Customer : "+Name);
System.out.println("\n Balance Amount :"+Bal);
Name : Vidit Abhilasha
}
}
class Bank
Name : Vidit Abhilasha
{
public static void main(String args[])
{
Account A1=new Account();
DataInputStream in=new DataInputStream(System.in);
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
String n,ta;
float amt,draw;
int an,m;
try
{
System.out.println("\nEnter The Name Of Customer");
n=in.readLine();
System.out.println("\nEnter The Account Number Of Customer");
an=Integer.parseInt(in.readLine());
System.out.println("\nEnter The Type Of Account Of Customer");
ta=in.readLine();
A1.Getdata(n,an,ta);
case 1:
{
{
A1.Display();
break;
}
Name : Vidit Abhilasha
default:
{
System.out.print("\n Wrong Choice");
break;
}
}
}
catch(Exception e)
{}
}
}
OutPut:
while(i<n)
{
sum+=Math.pow(x,i);
i++;
}
System.out.println("Sum of Series 1+X+X^2+X^3+....= " +sum);
}
}
Output:
Output:
1Fives are 5
Name : Vidit Abhilasha
1Sevens are 7
1Thirteens are 13
2Fives are 10
2Sevens are 14
Name : Vidit Abhilasha
2Thirteens are 26
3Fives are 15
3Sevens are 21
3Thirteens are 39
4Fives are 20
4Sevens are 28
4Thirteens are 52
5Fives are 25
5Sevens are 35
5Thirteens are 65
Name : Vidit Abhilasha
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.*;
calc(String title)
{
super(title);
l1 = new JLabel("0");
l1.setHorizontalAlignment(JTextField.RIGHT);
p1.add(b7);
p1.add(b8);
p1.add(b9);
p1.add(b4);
Name : Vidit Abhilasha
p1.add(b5);
p1.add(b6);
p1.add(b1);
p1.add(b2);
Name : Vidit Abhilasha
p1.add(b3);
p1.add(b0);
p1.add(bequal);
p1.add(bdiv);
p1.add(badd);
p1.add(bsub);
p1.add(bmul);
con.setLayout(new BorderLayout());
con.add(l1, BorderLayout.NORTH);
con.add(p1, BorderLayout.CENTER);
int op;
String bval;
{
this.c1=c1;
}
a=0;
op=3;
}
else
Name : Vidit Abhilasha
if(e.getSource() == c1.bdiv)
{
sa = c1.l1.getText();
b = Integer.parseInt(sa);
c1.l1.setText("0");
a=0;
op=4;
}
else
{
bval = e.getActionCommand();
a = a* 10 + Integer.parseInt(bval);
c1.l1.setText(Integer.toString(a));
}
}
}
Output: