Java Projects Source Codes
Java Projects Source Codes
import java.io.*;
import java.lang.*;
int sc=0;
System.out.println("========================================
========================");
System.out.println("1.***SPORTS***");
System.out.println("2.***INDIAN ECONOMY***");
System.out.println("3.***GENERAL KNOWLEDGE***");
int choice=Integer.parseInt(in.readLine());
if(choice==1)
System.out.println("`````````````````````````````````````````");
System.out.println();
System.out.println("=====1.sachin tendulkar======");
System.out.println("=====2.saurav ganguly======");
System.out.println("=====3.yuvraj singh======");
System.out.println("=====4.rahul dravid======");
int aa=Integer.parseInt(in.readLine());
if(aa==4)
sc=sc+50;
else
System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT
ANSWER IS RAHUL DRAVID");
System.out.println();
System.out.println("=====2.jacques kallis======");
System.out.println("=====3.brian lara======");
System.out.println("=====4.chris harris======");
int ab=Integer.parseInt(in.readLine());
if(ab==3)
sc=sc+50;
else
System.out.println();
System.out.println("=====2.personal box======");
System.out.println("=====3.pin ball======");
System.out.println("=====4.play banned======");
int ac=Integer.parseInt(in.readLine());
if(ac==2)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.200m ======");
System.out.println("=====2.800m======");
System.out.println("=====3.600m======");
System.out.println("=====4.400m======");
System.out.println("+++++ENTER YOUR CHOICE+++++");
int ad=Integer.parseInt(in.readLine());
if(ad==2)
sc=sc+50;
else
System.out.println();
System.out.println("=====3.wimbledon======");
int ae=Integer.parseInt(in.readLine());
if(ae==3)
{
System.out.println("`````you are on the right track`````");
sc=sc+50;
else
System.out.println();
System.out.println("=====1.gold ======");
System.out.println("=====2.platinum ======");
System.out.println("=====3.silver======");
System.out.println("=====4.copper======");
int af=Integer.parseInt(in.readLine());
if(af==1)
sc=sc+50;
}
else
System.out.println();
System.out.println("=====1.volley ball======");
System.out.println("=====3.base ball======");
int ag=Integer.parseInt(in.readLine());
if(ag==2)
sc=sc+50;
else
System.out.println();
System.out.println("8)who was the first cricketer to score 1000test
runs,played 100test matches and took 100test catches?");
System.out.println("=====1.garfield sobers======");
System.out.println("=====2.allan donald======");
System.out.println("=====3.ian chappel======");
System.out.println("=====4.kapil dev======");
int ah=Integer.parseInt(in.readLine());
if(ah==1)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.5 ======");
System.out.println("=====2.6 ======");
System.out.println("=====3.8======");
System.out.println("=====4.11 ======");
int ai=Integer.parseInt(in.readLine());
if(ai==2)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.1930 ======");
System.out.println("=====2.1934======");
System.out.println("=====3.1938======");
System.out.println("=====4.1948======");
int aj=Integer.parseInt(in.readLine());
if(aj==1)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.madrid======");
System.out.println("=====2.tokyo======");
System.out.println("=====3.Buenos Aires======");
System.out.println("=====4.Istanbul======");
int ak=Integer.parseInt(in.readLine());
if(ak==2)
sc=sc+50;
else
System.out.println();
int al=Integer.parseInt(in.readLine());
if(al==2)
sc=sc+50;
else
System.out.println("=====1.24======");
System.out.println("=====2.36======");
System.out.println("=====3.48======");
System.out.println("=====4.64======");
int am=Integer.parseInt(in.readLine());
if(am==4)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.Iran======");
System.out.println("=====2.Pakistan======");
System.out.println("=====3.Thailand======");
System.out.println("=====4.Philippines======");
int an=Integer.parseInt(in.readLine());
if(an==2)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.Los Angeles======");
System.out.println("=====2.Amsterdam======");
System.out.println("=====3.Berlin======");
System.out.println("=====4.London======");
int ao=Integer.parseInt(in.readLine());
if(ao==2)
sc=sc+50;
else
if(sc<200)
if(sc>=200&&sc<500)
if(sc>500&&sc<=750)
}
if(choice==2)
System.out.println("=====1.china ======");
System.out.println("=====2.japan ======");
System.out.println("=====3.india======");
System.out.println("=====4.pakistan ======");
int ba=Integer.parseInt(in.readLine());
if(ba==3)
sc=sc+50;
else
System.out.println();
System.out.println("=====3.Microfinance Institutions======");
int bb=Integer.parseInt(in.readLine());
if(bb==2)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.Agriculture Finance
Corporation======");
System.out.println("=====3.Finance commission======");
System.out.println("=====4.Inter State Council======");
int bc=Integer.parseInt(in.readLine());
if(bc==3)
sc=sc+50;
else
System.out.println();
int bd=Integer.parseInt(in.readLine());
if(bd==3)
{
System.out.println("`````you are on the right track`````");
sc=sc+50;
else
System.out.println();
System.out.println("=====1.Mulching ======");
System.out.println("=====4.Terracing======");
int be=Integer.parseInt(in.readLine());
if(be==2)
sc=sc+50;
}
else
System.out.println();
System.out.println("=====1.2005 ======");
System.out.println("=====2.2007 ======");
System.out.println("=====3.2008======");
System.out.println("=====4.2009======");
int bf=Integer.parseInt(in.readLine());
if(bf==2)
sc=sc+50;
else
System.out.println();
System.out.println("7)The head office of the National Bank for
Agriculture and Rural Development(NABARD)?");
System.out.println("=====1.Hyderabad======");
System.out.println("=====2.Lucknow======");
System.out.println("=====3.New Delhi======");
System.out.println("=====4.Mumbai======");
int bg=Integer.parseInt(in.readLine());
if(bg==4)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.Oilseed production======");
System.out.println("=====2.Fish production======");
System.out.println("=====3.Milk production======");
System.out.println("=====4.Food grain production======");
int bh=Integer.parseInt(in.readLine());
if(bh==2)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.NAFED======");
System.out.println("=====2.TRI FED======");
System.out.println("=====3.NCDC======");
System.out.println("=====4.IFFCO======");
int bi=Integer.parseInt(in.readLine());
if(bi==4)
{
sc=sc+50;
else
System.out.println();
System.out.println("=====1.Rice======");
System.out.println("=====2.Pulses======");
System.out.println("=====3.Oilseeds======");
System.out.println("=====4.Wheat======");
int bj=Integer.parseInt(in.readLine());
if(bj==4)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.Kanpur======");
System.out.println("=====2.Cuttack======");
System.out.println("=====3.Bangalore======");
System.out.println("=====4.Coimbatore======");
int bk=Integer.parseInt(in.readLine());
if(bk==2)
sc=sc+50;
else
System.out.println("=====1.B.P. Pal======");
System.out.println("=====2.K.N. Bhal======");
System.out.println("=====3.V. Kurien======");
int bl=Integer.parseInt(in.readLine());
if(bl==3)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.Kanpur======");
System.out.println("=====2.Delhi======");
System.out.println("=====3.Bangalore======");
System.out.println("=====4.Pant Nagar======");
int bm=Integer.parseInt(in.readLine());
if(bm==4)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.Banking======");
System.out.println("=====2.Capital marketing======");
System.out.println("=====3.Sugar marketing======");
int bn=Integer.parseInt(in.readLine());
if(bn==4)
{
sc=sc+50;
else
System.out.println();
int bo=Integer.parseInt(in.readLine());
if(bo==3)
sc=sc+50;
else
if(sc<200)
if(sc>=200&&sc<500)
if(sc>500&&sc<=750)
if(choice==3)
System.out.println("=====1.mother teresa======");
System.out.println("=====2.arundhati roy======");
System.out.println("=====3.ameliya arhart======");
System.out.println("=====4.rabindranath tagore======");
int ca=Integer.parseInt(in.readLine());
if(ca==1)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.mahatma gandhi======");
System.out.println("=====2.B.R.ambedkar======");
if(cb==1)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.captain======");
System.out.println("=====2.brigadier======");
System.out.println("=====3.lieuntenant general======");
System.out.println("=====4.major======");
int cc=Integer.parseInt(in.readLine());
if(cc==3)
else
System.out.println();
System.out.println("=====1.dharmendra======");
System.out.println("=====2.amithbh bachchan======");
System.out.println("=====3.rajesh khanna======");
System.out.println("=====4.jitendra======");
int cd=Integer.parseInt(in.readLine());
if(cd==2)
sc=sc+50;
else
System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT
ANSWER IS AMITHBH BACHCHAN");
System.out.println();
System.out.println("=====1.stick======");
System.out.println("=====2.bag======");
System.out.println("=====3.hat======");
System.out.println("=====4.cartoon mask======");
int ce=Integer.parseInt(in.readLine());
if(ce==1)
sc=sc+50;
else
System.out.println();
System.out.println("=====2.china======");
System.out.println("=====3.japan======");
System.out.println("=====4.australia======");
int cf=Integer.parseInt(in.readLine());
if(cf==1)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.red======");
System.out.println("=====2.blue======");
System.out.println("=====3.white======");
System.out.println("=====4.yellow======");
System.out.println("+++++ENTER YOUR CHOICE+++++");
int cg=Integer.parseInt(in.readLine());
if(cg==3)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.june 21======");
System.out.println("=====2.january 15======");
System.out.println("=====3.july 16======");
System.out.println("=====4.december21======");
int ch=Integer.parseInt(in.readLine());
if(ch==1)
else
System.out.println();
System.out.println("=====2.cosmetics======");
System.out.println("=====3.space======");
System.out.println("=====4.medicine======");
String v11=in.readLine();
int ci=Integer.parseInt(in.readLine());
if(ci==1)
sc=sc+50;
}
else
System.out.println();
System.out.println("=====1.Iron Ore======");
System.out.println("=====2.Bauxite======");
System.out.println("=====3.Mica======");
System.out.println("=====4.Mercury======");
int cj=Integer.parseInt(in.readLine());
if(cj==4)
sc=sc+50;
else
System.out.println();
System.out.println("11)The last Mughal Emperor was?");
System.out.println("=====1.Akbar======");
System.out.println("=====2.Bahadur Shah======");
System.out.println("=====3.NoorJehan======");
System.out.println("=====4.Iltumish======");
int ck=Integer.parseInt(in.readLine());
if(ck==2)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.Haryana======");
System.out.println("=====2.Punjab======");
System.out.println("=====3.Karnataka======");
System.out.println("=====4.Tamil Nadu======");
int cl=Integer.parseInt(in.readLine());
if(cl==2)
sc=sc+50;
else
System.out.println();
System.out.println("=====1.The Alps======");
System.out.println("=====2.The Himalayas======");
System.out.println("=====3.The Andes======");
System.out.println("=====4.The Rockies======");
int cm=Integer.parseInt(in.readLine());
if(cm==3)
{
sc=sc+50;
else
System.out.println();
System.out.println("=====1.Paris======");
System.out.println("=====2.London======");
System.out.println("=====3.Peking ======");
System.out.println("=====4.Tokyo ======");
int cn=Integer.parseInt(in.readLine());
if(cn==4)
sc=sc+50;
}
else
System.out.println();
System.out.println("=====1.Oct 4 ======");
System.out.println("=====2.Oct 31 ======");
System.out.println("=====3.Nov 14======");
System.out.println("=====4.Nov 19======");
int co=Integer.parseInt(in.readLine());
if(co==1)
sc=sc+50;
else
{
System.out.println("%%%%%FINALLY YOU HAVE
SCORED="+sc+"POINTS%%%%%%");
if(sc<200)
if(sc>=200&&sc<500)
if(sc>500&&sc<=750)
}
BANKING
import java.io.*;
import java.util.*;
class Account
String Name,Password;
int AccNo,Money;
int dd,mm,yy;
Name=n;
AccNo=an;
dd=d;
mm=m;
yy=y;
Money=mon;
Password=p;
{
System.out.println(AccNo+"\t"+Name+"\t\t"+dd+"/"+mm+"/"+yy+"\t
"+Money+"\t\t"+Password);
int ch=1;
startAccount();
do
{
switch(ch)
}while(ch<=5);
}
private static void createAccount() throws IOException
Calendar c=Calendar.getInstance();
int date=c.get(Calendar.DATE);
int month=c.get(Calendar.MONTH);
int year=c.get(Calendar.YEAR);
String n,p;
int m;
n=x.readLine();
m=Integer.parseInt(x.readLine());
p=x.readLine();
Acc[Ano]=new Account(n,Ano,date,month,year,m,p);
Ano++;
String p;
int no,amt;
no=Integer.parseInt(x.readLine());
System.out.print("Password : ");
p=x.readLine();
System.out.println("Welcome "+Acc[no].Name);
amt=Integer.parseInt(x.readLine());
if(amt<=Acc[no].Money)
Acc[no].Money-=amt;
else
else
String p;
int no,amt;
no=Integer.parseInt(x.readLine());
System.out.print("Password : ");
p=x.readLine();
System.out.println("Welcome "+Acc[no].Name);
amt=Integer.parseInt(x.readLine());
Acc[no].Money+=amt;
else
String p;
int no,amt;
no=Integer.parseInt(x.readLine());
System.out.print("Password : ");
p=x.readLine();
int rate=(Acc[no].Money>=20000)?18:10;
int interest=Acc[no].Money*rate/100;
System.out.println("Current Balance :
"+(Acc[no].Money+interest));
else
System.out.println("Acc\tName\t\tDate\t\tMoney\t\tPassword");
for(int i=1;i<Ano;i++)
Acc[i].displayData();
Acc[Ano]=new Account("Sachin",Ano,date,month,year,500,"ABC");
Ano++;
Acc[Ano]=new Account("Sourav",Ano,date,month,year,500,"XYZ");
Ano++;
Acc[Ano]=new
Account("Shewag",Ano,date,month,year,500,"MNO"); Ano++;
}
RAILWAY RESERVATION SYSTEM
import java.io.*;
int pcount=0;
int pnum=1;
int max1=75;
int max2=125;
int max3=175;
int cho=0;
do
{
System.out.println("\f");
doHeading();
System.out.println("1.Book ticket");
System.out.println("2.Cancel ticket");
System.out.println("3.Search passenger");
System.out.println("4.Reservation chart");
System.out.println("6.Exit");
cho=Integer.parseInt(br.readLine());
switch(cho)
}
char e=(char)br.read();
}while(cho!=6);
System.out.println("########################################
#################");
System.out.println("########################################
#################");
int c=Integer.parseInt(br.readLine());
int t=Integer.parseInt(br.readLine());
int ticketAvailable=0;
ticketAvailable=1;
ticketAvailable=1;
ticketAvailable=1;
if(ticketAvailable==1)
for(int i=0;i<t;i++)
pno[pcount]=pnum;
name[pcount]=br.readLine();
age[pcount]=Integer.parseInt(br.readLine());
cl[pcount]=c;
System.out.println("Please enter your phno");
phno[pcount]=br.readLine();
pcount++;
pnum++;
}//for
if(c==1)
max1-=t;
if(c==2)
max2-=t;
if(c==3)
max3-=t;
}
}
int t_pcount=0;
int passengerFound=0;
int p=Integer.parseInt(br.readLine());
for(int i=0;i<pcount;i++)
if(pno[i]!=p)
{//transfer
t_pno[t_pcount]=pno[i];
t_name[t_pcount]=name[i];
t_phno[t_pcount]=phno[i];
t_age[t_pcount]=age[i];
t_cl[t_pcount]=cl[i];
t_pcount++;
else
passengerFound=1;
if(cl[i]==1)
max1++;
if(cl[i]==2)
max2++;
if(cl[i]==3)
max3++;
}//else
}//if
if(passengerFound==1)
pno=t_pno;
name=t_name;
age=t_age;
cl=t_cl;
phno=t_phno;
pcount=t_pcount;
}//method
for(int i=0;i<pcount;i++)
if(cl[i]==1)
{
System.out.println(pno[i]+"\t"+name[i]+"\t\t"+age[i]+"\t"+phno[i]);
for(int i=0;i<pcount;i++)
if(cl[i]==2)
System.out.println(pno[i]+"\t"+name[i]+"\t\t"+age[i]+"\t"+phno[i]);
for(int i=0;i<pcount;i++)
if(cl[i]==3)
System.out.println(pno[i]+"\t"+name[i]+"\t\t"+age[i]+"\t"+phno[i]);
}
}
int passengerFound=0;
int p=Integer.parseInt(br.readLine());
for(int i=0;i<pcount;i++)
if(pno[i]==p)
System.out.println("Detail found");
passengerFound=1;
System.out.println("passenger no.="+pno[i]);
System.out.println("name="+name[i]);
System.out.println("class="+cl[i]);
System.out.println("phno="+phno[i]);
System.out.println("age="+age[i]);
}//for
if(passengerFound==0)
System.out.println("AC class"+max1);
System.out.println("First class"+max2);
System.out.println("Sleeper class"+max3);
System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&");
System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&");
}
CALENDER
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
{
protected int yy;
/** The number of day squares to leave blank at the start of this
month */
/**
*/
Calender()
super();
setYYMMDD(calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH));
buildGUI();
recompute();
/**
* Construct a Cal, given the leading days and the total days
* @exception IllegalArgumentException
*/
super();
buildGUI();
recompute();
yy = year;
mm = month;
dd = today;
/** Build the GUI. Assumes that setYYMMDD has been called. */
getAccessibleContext().setAccessibleDescription(
setBorder(BorderFactory.createEtchedBorder());
setLayout(new BorderLayout());
monthChoice.addItem(months[i]);
monthChoice.setSelectedItem(months[mm]);
monthChoice.addActionListener(new ActionListener()
int i = monthChoice.getSelectedIndex();
if (i >= 0) {
mm = i;
// System.out.println("Month=" + mm);
recompute();
});
monthChoice.getAccessibleContext().setAccessibleName("Months");
monthChoice.getAccessibleContext().setAccessibleDescription(
yearChoice.setEditable(true);
yearChoice.addItem(Integer.toString(i));
yearChoice.setSelectedItem(Integer.toString(yy));
yearChoice.addActionListener(new ActionListener()
int i = yearChoice.getSelectedIndex();
if (i >= 0) {
yy = Integer.parseInt(yearChoice.getSelectedItem()
.toString());
//System.out.println("Year=" + yy);
recompute();
});
add(BorderLayout.CENTER, tp);
bp.add(new JButton("M"));
bp.add(new JButton("T"));
bp.add(new JButton("W"));
bp.add(new JButton("R"));
bp.add(new JButton("F"));
bp.add(new JButton("S"));
ActionListener dateSetter = new ActionListener()
if (!num.equals(""))
setDayActive(Integer.parseInt(num));
};
add(BorderLayout.SOUTH, bp);
public final static int dom[] = { 31, 28, 31, 30,31, 30, 31, 31,30, 31,
30, 31};
clearDayActive();
++daysInMonth;
labs[0][i].setText("");
b.setText(Integer.toString(i));
// 7 days/week * up to 6 rows
repaint();
/**
*/
return true;
return false;
// System.out.println("Cal::setDate");
this.yy = yy;
this.dd = dd;
recompute();
JButton b;
if (activeDay > 0)
b.repaint();
activeDay = -1;
clearDayActive();
if (newDay <= 0)
dd = new GregorianCalendar().get(Calendar.DAY_OF_MONTH);
else
dd = newDay;
square.setBackground(Color.red);
square.repaint();
activeDay = newDay;
Container c = f.getContentPane();
c.setLayout(new FlowLayout());
c.add(new Calender());
f.pack();
f.setVisible(true);