Showing posts with label codings. Show all posts
Showing posts with label codings. Show all posts

Sunday, 30 March 2014

JAVA PROGRAMS-Bank Transaction

Program Name:- Bank Transaction

import java.io.*;
class bankacc
{
int withdraw,deposite,amt;
int accbal;
static String accname;
static int accno;
public void withdraw()throws IOException
{
DataInputStream inp=new DataInputStream(System.in);
System.out.println("enter the amount for withdraw");
amt=Integer.parseInt(inp.readLine());
if(accbal<amt)
{
System.out.println("You can't withdraw amount");
}
else
{
accbal=accbal-amt;
}
}
public void deposite()throws IOException
{
DataInputStream inp=new DataInputStream(System.in);
System.out.println("enter the amount for deposite");
amt=Integer.parseInt(inp.readLine());
accbal=accbal+amt;
}
public void disp()
{
System.out.println("account name\t:"+accname);
System.out.println("\naccount number\t:"+accno);
System.out.println("\nbalance\t:"+accbal);
}
public static void main(String args[])throws IOException
{
DataInputStream inp=new DataInputStream(System.in);
bankacc bd=new bankacc();
System.out.println("enter the accno:");
accno=Integer.parseInt(inp.readLine());
System.out.println("enter the accname");
accname=inp.readLine();
int c=0,ch;
while(c==0)
{
System.out.println("1.deposite\n");
System.out.println("2.withdraw\n");
System.out.println("3.display");
System.out.println("\n 4.enter your choice\n");
ch=Integer.parseInt(inp.readLine());
if(ch==1)
bd.deposite();
else if(ch==2)
bd.withdraw();
else
bd.disp();
System.out.println("do you want continue enter the 0");
c=Integer.parseInt(inp.readLine());
}
}
}


OUTPUT;-


Compile:-

c:\javaprograms>javac banckacc.java


RUN:-


c:\javaprograms>java bankacc


Enter the account number:

1

Enter the account name:

Ajith

1.Deposit

2.Withdraw

3.Display

Enter your choice:

1

Enter the amount to deposite:

500

Do you want to continue:

0

1.Deposit

2.Withdraw

3.Display

Enter your choice:

3

Account Name:Ajith

Account Number:1

Balance:500

Do you want to continue:

0


1.Deposit

2.Withdraw

3.Display

Enter your choice:

2

Enter the amount of withdraw:

260

Do you want to continue:

0


1.Deposit

2.Withdraw

3.Display

Enter your choice:

3


Account Name:Ajith

Account number:1

Balance:240


Do you want to continue:

1

Java Programs - Alphabetical order of the given Name

 Alphabetical order of the given Name


Program Name:-    alpha.java


import java.io.*;
import java.lang.*;
class alpha
{
public static void main(String args[])throws IOException
 {
 String a[]=new String[10];
 String b;
 int n;
 DataInputStream in=new DataInputStream(System.in);
 System.out.print("\nEnter the Number of name  :");
 n=Integer.parseInt(in.readLine());
 for(int i=0;i<n;i++)
  {
  a[i]=in.readLine();
  }
  for(int i=0;i<n;i++)
  {
  for(int j=i+1;j<n;j++)
   {
    if(a[i].compareTo(a[j])<0)
    {
    b=a[i];
    a[i]=a[j];
    a[j]=b;
    }
   }
  }
 System.out.println("\n Alphabetical order of name is:");
 for(int i=0;i<n;i++)
 {
 System.out.println(a[i]);
 }
 }
}