Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
1K views

Java Projects Source Codes

This Java program is a sports quiz that asks the user 15 multiple choice sports-related questions. For each question, the user inputs their answer choice and the program tells them if they are correct or incorrect, keeping track of their overall score. If correct, 50 points are added to their score. After all 15 questions, the user is shown their final score.

Uploaded by

prathamesh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Java Projects Source Codes

This Java program is a sports quiz that asks the user 15 multiple choice sports-related questions. For each question, the user inputs their answer choice and the program tells them if they are correct or incorrect, keeping track of their overall score. If correct, 50 points are added to their score. After all 15 questions, the user is shown their final score.

Uploaded by

prathamesh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 73

QUIZ

import java.io.*;

import java.lang.*;

public class QUIZ

public static void main (String args[])throws IOException

int sc=0;

InputStreamReader read=new InputStreamReader(System.in);

BufferedReader in=new BufferedReader(read);

System.out.println("***WELCOME TO THE WORLD OF QUIZ LET US


SEE HOW FAR YOU CAN GO***");

System.out.println("========================================
========================");

System.out.println("You can just enter the option number which you


feel correct");

System.out.println("1.***SPORTS***");

System.out.println("2.***INDIAN ECONOMY***");

System.out.println("3.***GENERAL KNOWLEDGE***");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int choice=Integer.parseInt(in.readLine());
if(choice==1)

System.out.println("`````GET READY FOR THE BRAIN STORM````");

System.out.println("`````````````````````````````````````````");

System.out.println("YOU CAN JUST ENTER THE OPTION NUMBER


WHICH YOU FEEL TRUE");

System.out.println();

System.out.println("1)Which indian cricketer is popularly called


'jammy'");

System.out.println("=====1.sachin tendulkar======");

System.out.println("=====2.saurav ganguly======");

System.out.println("=====3.yuvraj singh======");

System.out.println("=====4.rahul dravid======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int aa=Integer.parseInt(in.readLine());

if(aa==4)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else
System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT
ANSWER IS RAHUL DRAVID");

System.out.println();

System.out.println("2)which is the only cricketer to score a four


hundred(not out)?");

System.out.println("=====1.ricky ponting ======");

System.out.println("=====2.jacques kallis======");

System.out.println("=====3.brian lara======");

System.out.println("=====4.chris harris======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ab=Integer.parseInt(in.readLine());

if(ab==3)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS BRIAN LARA ");

System.out.println();

System.out.println("3)what would the letters PB next to an athlete's


name signify?");
System.out.println("=====1.post box ======");

System.out.println("=====2.personal box======");

System.out.println("=====3.pin ball======");

System.out.println("=====4.play banned======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ac=Integer.parseInt(in.readLine());

if(ac==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS PERSONAL BEST ");

System.out.println();

System.out.println("4)what is the shortest distance in a track and


field event where the runners are allowed to break lanes?");

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)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS 800m ");

System.out.println();

System.out.println("5)the standard colours of which sporting event


are green and purple?");

System.out.println("=====1.davis cup ======");

System.out.println("=====2.asia cup ======");

System.out.println("=====3.wimbledon======");

System.out.println("=====4.euro cup ======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ae=Integer.parseInt(in.readLine());

if(ae==3)

{
System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS WIMBLEDON ");

System.out.println();

System.out.println("6)the olympic gold medal consists 5.2% of which


metal?");

System.out.println("=====1.gold ======");

System.out.println("=====2.platinum ======");

System.out.println("=====3.silver======");

System.out.println("=====4.copper======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int af=Integer.parseInt(in.readLine());

if(af==1)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

}
else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS GOLD ");

System.out.println();

System.out.println("7)which of these games is officially played only


by girls?");

System.out.println("=====1.volley ball======");

System.out.println("=====2.net ball ======");

System.out.println("=====3.base ball======");

System.out.println("=====4.lawn tennis ======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ag=Integer.parseInt(in.readLine());

if(ag==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS NET BALL ");

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======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ah=Integer.parseInt(in.readLine());

if(ah==1)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS GARFIELD SOBERS");

System.out.println();

System.out.println("9)how many players are there in the game of


basket ball?");

System.out.println("=====1.5 ======");

System.out.println("=====2.6 ======");
System.out.println("=====3.8======");

System.out.println("=====4.11 ======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ai=Integer.parseInt(in.readLine());

if(ai==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS 6");

System.out.println();

System.out.println("10)when was the first common wealth games


held?");

System.out.println("=====1.1930 ======");

System.out.println("=====2.1934======");

System.out.println("=====3.1938======");

System.out.println("=====4.1948======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int aj=Integer.parseInt(in.readLine());
if(aj==1)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS 1930");

System.out.println();

System.out.println("11)The FIFA World Cup 2018 was be held in?");

System.out.println("=====1.madrid======");

System.out.println("=====2.tokyo======");

System.out.println("=====3.Buenos Aires======");

System.out.println("=====4.Istanbul======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ak=Integer.parseInt(in.readLine());

if(ak==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);


}

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS TOKYO");

System.out.println();

System.out.println("12)Antony De Mello Trophy is associated with


test cricket series played between?");

System.out.println("=====1.Australia and India======");

System.out.println("=====2.England and India======");

System.out.println("=====3.South Africa and India======");

System.out.println("=====4.England and Australia======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int al=Integer.parseInt(in.readLine());

if(al==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS ENGLAND AND INDIA");
System.out.println();

System.out.println("13)How many squares are there in a Chess


Board?");

System.out.println("=====1.24======");

System.out.println("=====2.36======");

System.out.println("=====3.48======");

System.out.println("=====4.64======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int am=Integer.parseInt(in.readLine());

if(am==4)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS 64");

System.out.println();

System.out.println("14)Which of the following countries has not


been a host of Asian Games?");

System.out.println("=====1.Iran======");
System.out.println("=====2.Pakistan======");

System.out.println("=====3.Thailand======");

System.out.println("=====4.Philippines======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int an=Integer.parseInt(in.readLine());

if(an==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS PAKISTAN");

System.out.println();

System.out.println("15)India first won the Olympic Hockey gold at?");

System.out.println("=====1.Los Angeles======");

System.out.println("=====2.Amsterdam======");

System.out.println("=====3.Berlin======");

System.out.println("=====4.London======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ao=Integer.parseInt(in.readLine());
if(ao==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS AMSTERDAM");

System.out.println("%%%%%FINALLY YOU HAVE


SCORED="+sc+"POINTS%%%%%%");

if(sc<200)

System.out.println("!!!!!SORRY! WE DON'T HAVE A PRIZE FOR


YOU!!!!!");

if(sc>=200&&sc<500)

System.out.println("!!!!!CONGRATULATIONS! YOU WIN A BIG GRAND


CHEQUE OF Rs50000!!!");

if(sc>500&&sc<=750)

System.out.println("!!!!!CONGRATULATIONS! YOU WIN A BIG GRAND


CHEQUE OF Rs100000!!!!");

}
if(choice==2)

System.out.println("1)which country is the largest producer of


milk?");

System.out.println("=====1.china ======");

System.out.println("=====2.japan ======");

System.out.println("=====3.india======");

System.out.println("=====4.pakistan ======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ba=Integer.parseInt(in.readLine());

if(ba==3)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS INDIA");

System.out.println();

System.out.println("2)In India, which of the following has the highest


share in the disbursement of credit to agriculture and allied
activities??");
System.out.println("=====1.Co-operative Banks ======");

System.out.println("=====2.Commercial Banks ======");

System.out.println("=====3.Microfinance Institutions======");

System.out.println("=====4.Regional Rural Banks======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bb=Integer.parseInt(in.readLine());

if(bb==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS COMMERCIAL BANKS");

System.out.println();

System.out.println("3)Which one of the following agencies assigns


the Agricultural Income Tax to States in India? ?");

System.out.println("=====1.Agriculture Finance
Corporation======");

System.out.println("=====2.National Development Council ======");

System.out.println("=====3.Finance commission======");
System.out.println("=====4.Inter State Council======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bc=Integer.parseInt(in.readLine());

if(bc==3)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS FINANCE COMMISSION");

System.out.println();

System.out.println("4)NABARD was established in the?");

System.out.println("=====1.Fourth Five year Plan ======");

System.out.println("=====2.Fifth Five Year Plan ======");

System.out.println("=====3.Sixth Five Year Plan======");

System.out.println("=====4.Eighth Five Year Plan ======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bd=Integer.parseInt(in.readLine());

if(bd==3)

{
System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS SIXTH FIVE YEAR PLAN");

System.out.println();

System.out.println("5)Which one of the following methods of soil


conservation is most effective in ariel areas?");

System.out.println("=====1.Mulching ======");

System.out.println("=====2.Shelter belt ======");

System.out.println("=====3.Gully plugging ======");

System.out.println("=====4.Terracing======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int be=Integer.parseInt(in.readLine());

if(be==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

}
else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS SHELTER BELT");

System.out.println();

System.out.println("6)Rashtriya Krishi Vika Yojna was launched in the


year?");

System.out.println("=====1.2005 ======");

System.out.println("=====2.2007 ======");

System.out.println("=====3.2008======");

System.out.println("=====4.2009======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bf=Integer.parseInt(in.readLine());

if(bf==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS 2007");

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======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bg=Integer.parseInt(in.readLine());

if(bg==4)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS MUMBAI");

System.out.println();

System.out.println("8)The Blue Revolution is related with?");

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======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bh=Integer.parseInt(in.readLine());

if(bh==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS FISH PRODUCTION");

System.out.println();

System.out.println("9)Which one of the following co-operative


societies is responsible for the production of fertilizers?");

System.out.println("=====1.NAFED======");

System.out.println("=====2.TRI FED======");

System.out.println("=====3.NCDC======");

System.out.println("=====4.IFFCO======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bi=Integer.parseInt(in.readLine());

if(bi==4)
{

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS IFFCO");

System.out.println();

System.out.println("10)The impact of the Green Revolution was felt


most in the production of?");

System.out.println("=====1.Rice======");

System.out.println("=====2.Pulses======");

System.out.println("=====3.Oilseeds======");

System.out.println("=====4.Wheat======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bj=Integer.parseInt(in.readLine());

if(bj==4)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);


}

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS WHEAT");

System.out.println();

System.out.println("11)Where is the central Rice Research institute


located?");

System.out.println("=====1.Kanpur======");

System.out.println("=====2.Cuttack======");

System.out.println("=====3.Bangalore======");

System.out.println("=====4.Coimbatore======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bk=Integer.parseInt(in.readLine());

if(bk==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS CUTTACK");
System.out.println();

System.out.println("12)Who is known as the father of 'White


Revolution' in India?");

System.out.println("=====1.B.P. Pal======");

System.out.println("=====2.K.N. Bhal======");

System.out.println("=====3.V. Kurien======");

System.out.println("=====4.M.S. Swaminathan ======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bl=Integer.parseInt(in.readLine());

if(bl==3)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS V.KURIEN");

System.out.println();

System.out.println("13)Green Revolution in India started from?");

System.out.println("=====1.Kanpur======");

System.out.println("=====2.Delhi======");
System.out.println("=====3.Bangalore======");

System.out.println("=====4.Pant Nagar======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bm=Integer.parseInt(in.readLine());

if(bm==4)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS PANT NAGAR");

System.out.println();

System.out.println("14)Swaroop committee is associated with?");

System.out.println("=====1.Banking======");

System.out.println("=====2.Capital marketing======");

System.out.println("=====3.Sugar marketing======");

System.out.println("=====4.Financial products marketing======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bn=Integer.parseInt(in.readLine());

if(bn==4)
{

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS FINANCIAL PRODUCTS MARKETING");

System.out.println();

System.out.println("15)Which one of the following five year plans


has the highest GDP growth rate in Agriculture sector in India?");

System.out.println("=====1.Sixth Five Year Plan======");

System.out.println("=====2.Seventh Five Year Plan======");

System.out.println("=====3.Eighth Five Year Plan======");

System.out.println("=====4.Ninth Five Year Plan======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int bo=Integer.parseInt(in.readLine());

if(bo==3)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);


}

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS EIGHTH FIVE YEAR PLAN");

System.out.println("%%%%%FINALLY YOU HAVE


SCORED="+sc+"POINTS%%%%%%");

if(sc<200)

System.out.println("!!!!!SORRY! WE DON'T HAVE A PRIZE FOR


YOU!!!!!");

if(sc>=200&&sc<500)

System.out.println("!!!!!CONGRATULATIONS! YOU WIN A BIG GRAND


CHEQUE OF Rs50000!!!");

if(sc>500&&sc<=750)

System.out.println("!!!!!CONGRATULATIONS! YOU WIN A BIG GRAND


CHEQUE OF Rs100000!!!!");

if(choice==3)

System.out.println("1)something beautiful for god is a book by


malcolm muggeridge. who is the subject of this book?");

System.out.println("=====1.mother teresa======");
System.out.println("=====2.arundhati roy======");

System.out.println("=====3.ameliya arhart======");

System.out.println("=====4.rabindranath tagore======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ca=Integer.parseInt(in.readLine());

if(ca==1)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS MOTHER TERESA");

System.out.println();

System.out.println("2)which indian has the most number of roads


named after him?");

System.out.println("=====1.mahatma gandhi======");

System.out.println("=====2.B.R.ambedkar======");

System.out.println("=====3.subhash chandra bose======");

System.out.println("=====4.jawahar lal nehru======");

System.out.println("+++++ENTER YOUR CHOICE+++++");


int cb=Integer.parseInt(in.readLine());

if(cb==1)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS MAHATMA GANDHI");

System.out.println();

System.out.println("3)if an indian army officer has three stars on his


car plate, what is his rank?");

System.out.println("=====1.captain======");

System.out.println("=====2.brigadier======");

System.out.println("=====3.lieuntenant general======");

System.out.println("=====4.major======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int cc=Integer.parseInt(in.readLine());

if(cc==3)

System.out.println("`````you are on the right track`````");


sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS LIEUTENTANT GENERAL");

System.out.println();

System.out.println("4)who made his film debut in 'saat


hindustaani'?");

System.out.println("=====1.dharmendra======");

System.out.println("=====2.amithbh bachchan======");

System.out.println("=====3.rajesh khanna======");

System.out.println("=====4.jitendra======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int cd=Integer.parseInt(in.readLine());

if(cd==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else
System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT
ANSWER IS AMITHBH BACHCHAN");

System.out.println();

System.out.println("5)what did charlie chaplin always carry in his


hand?");

System.out.println("=====1.stick======");

System.out.println("=====2.bag======");

System.out.println("=====3.hat======");

System.out.println("=====4.cartoon mask======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ce=Integer.parseInt(in.readLine());

if(ce==1)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS STICK");

System.out.println();

System.out.println("6)in which country was the chess invented?");


System.out.println("=====1.india======");

System.out.println("=====2.china======");

System.out.println("=====3.japan======");

System.out.println("=====4.australia======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int cf=Integer.parseInt(in.readLine());

if(cf==1)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS MILK");

System.out.println();

System.out.println("7)the colour of the highest belt in karate is black.


what is the colour of the lowest belt?");

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)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS WHITE");

System.out.println();

System.out.println("8)which day is said to be the longest day?");

System.out.println("=====1.june 21======");

System.out.println("=====2.january 15======");

System.out.println("=====3.july 16======");

System.out.println("=====4.december21======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ch=Integer.parseInt(in.readLine());

if(ch==1)

System.out.println("`````you are on the right track`````");


sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS JUNE 21");

System.out.println();

System.out.println("9)if your mother was a horticulturist, what


would she be interested in?");

System.out.println("=====1.flowers and gardening======");

System.out.println("=====2.cosmetics======");

System.out.println("=====3.space======");

System.out.println("=====4.medicine======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

String v11=in.readLine();

int ci=Integer.parseInt(in.readLine());

if(ci==1)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

}
else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS FLOWERS AND GARDENING");

System.out.println();

System.out.println("10)The mineral in which India depends largely on


imports is?");

System.out.println("=====1.Iron Ore======");

System.out.println("=====2.Bauxite======");

System.out.println("=====3.Mica======");

System.out.println("=====4.Mercury======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int cj=Integer.parseInt(in.readLine());

if(cj==4)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS MERCURY");

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======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int ck=Integer.parseInt(in.readLine());

if(ck==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS BAHADUR SHAH");

System.out.println();

System.out.println("12)The state which leads in agricultural


production is?");

System.out.println("=====1.Haryana======");

System.out.println("=====2.Punjab======");

System.out.println("=====3.Karnataka======");
System.out.println("=====4.Tamil Nadu======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int cl=Integer.parseInt(in.readLine());

if(cl==2)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS PUNJAB");

System.out.println();

System.out.println("13)The longest mountain range in the world


is?");

System.out.println("=====1.The Alps======");

System.out.println("=====2.The Himalayas======");

System.out.println("=====3.The Andes======");

System.out.println("=====4.The Rockies======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int cm=Integer.parseInt(in.readLine());

if(cm==3)
{

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS THE ANDES");

System.out.println();

System.out.println("14)The most populous city in the world is?");

System.out.println("=====1.Paris======");

System.out.println("=====2.London======");

System.out.println("=====3.Peking ======");

System.out.println("=====4.Tokyo ======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int cn=Integer.parseInt(in.readLine());

if(cn==4)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

}
else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS TOKYO");

System.out.println();

System.out.println("15)National Integration Day is celebrated on?");

System.out.println("=====1.Oct 4 ======");

System.out.println("=====2.Oct 31 ======");

System.out.println("=====3.Nov 14======");

System.out.println("=====4.Nov 19======");

System.out.println("+++++ENTER YOUR CHOICE+++++");

int co=Integer.parseInt(in.readLine());

if(co==1)

System.out.println("`````you are on the right track`````");

sc=sc+50;

System.out.println("YOUR SCORE IS" +sc);

else

System.out.println("SORRY BETTER LUCK NEXT TIME THE CORRECT


ANSWER IS OCT 4");

{
System.out.println("%%%%%FINALLY YOU HAVE
SCORED="+sc+"POINTS%%%%%%");

if(sc<200)

System.out.println("!!!!!SORRY! WE DON'T HAVE A PRIZE FOR


YOU!!!!!");

if(sc>=200&&sc<500)

System.out.println("!!!!!CONGRATULATIONS! YOU WIN A BIG GRAND


CHEQUE OF Rs50000!!!");

if(sc>500&&sc<=750)

System.out.println("!!!!!CONGRATULATIONS! YOU WIN A BIG GRAND


CHEQUE OF Rs100000!!!!");

}
BANKING
import java.io.*;

import java.util.*;

class Account

String Name,Password;

int AccNo,Money;

int dd,mm,yy;

public Account(String n,int an,int d,int m,int y,int mon,String p)

Name=n;

AccNo=an;

dd=d;

mm=m;

yy=y;

Money=mon;

Password=p;

public void displayData()

{
System.out.println(AccNo+"\t"+Name+"\t\t"+dd+"/"+mm+"/"+yy+"\t
"+Money+"\t\t"+Password);

public class Bank

public static Calendar c=Calendar.getInstance();

public static int date=c.get(Calendar.DATE);

public static int month=c.get(Calendar.MONTH);

public static int year=c.get(Calendar.YEAR);

public static InputStreamReader isr=new


InputStreamReader(System.in);

public static BufferedReader x=new BufferedReader(isr);

public static int Ano=1;

public static Account Acc[]=new Account[100];

public static void main() throws IOException

int ch=1;

startAccount();

do
{

System.out.println(" Welcome to State Bank ");

System.out.println(" --: OPTION MENU :-- ");

System.out.println(" 1. Create Account ");

System.out.println(" 2. Withdrawl ");

System.out.println(" 3. Deposited ");

System.out.println(" 4. Checking Account ");

System.out.println(" 5. Checking Master ");

System.out.println(" 6. Exit ");

System.out.print( "Enter Your Choice(1-6) : ");

switch(ch)

case 1: createAccount(); break;

case 2: withdrawl(); break;

case 3: deposit(); break;

case 4: checkAccount(); break;

case 5: checkMaster(); break;

}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;

System.out.println("Your Account Number is : "+Ano);

System.out.print("Your Name : ");

n=x.readLine();

System.out.print("Opening Balance : ");

m=Integer.parseInt(x.readLine());

System.out.print("Your Password : ");

p=x.readLine();

Acc[Ano]=new Account(n,Ano,date,month,year,m,p);

Ano++;

private static void withdrawl() throws IOException

String p;
int no,amt;

System.out.print("Your Account Number : ");

no=Integer.parseInt(x.readLine());

System.out.print("Password : ");

p=x.readLine();

if(no<Ano && p.equals(Acc[no].Password))

System.out.println("Welcome "+Acc[no].Name);

System.out.print("Withdrawl Amount : ");

amt=Integer.parseInt(x.readLine());

if(amt<=Acc[no].Money)

Acc[no].Money-=amt;

else

System.out.println("Only "+Acc[no].Money+" amount left in


your Account");

else

System.out.println("Your are Unauthorized Customer");

private static void deposit() throws IOException

String p;
int no,amt;

System.out.print("Your Account Number : ");

no=Integer.parseInt(x.readLine());

System.out.print("Password : ");

p=x.readLine();

if(no<Ano && p.equals(Acc[no].Password))

System.out.println("Welcome "+Acc[no].Name);

System.out.print("Deposit Amount : ");

amt=Integer.parseInt(x.readLine());

Acc[no].Money+=amt;

else

System.out.println("Your are Unauthorized Customer");

private static void checkAccount() throws IOException

String p;

int no,amt;

System.out.print("Your Account No. : ");

no=Integer.parseInt(x.readLine());
System.out.print("Password : ");

p=x.readLine();

if(no<Ano && p.equals(Acc[no].Password))

System.out.println("Your Name : "+Acc[no].Name);

System.out.println("Balance Amount : "+Acc[no].Money);

int rate=(Acc[no].Money>=20000)?18:10;

System.out.println("Interest Rate : "+rate+"%");

int interest=Acc[no].Money*rate/100;

System.out.println("Current Balance :
"+(Acc[no].Money+interest));

else

System.out.println("Your are Unauthorized Customer");

private static void checkMaster()

System.out.println("Acc\tName\t\tDate\t\tMoney\t\tPassword");

for(int i=1;i<Ano;i++)

Acc[i].displayData();

private static void startAccount()


{

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.*;

public class RailwayReservation

InputStreamReader isr=new InputStreamReader (System.in);

BufferedReader br=new BufferedReader (isr);

//System.out.print("Please enter a word");

int pno[]=new int[275];

String name[]=new String[275];

String phno[]=new String[275];

int age[]=new int[275];

int cl[]=new int[275];

int pcount=0;

int pnum=1;

int max1=75;

int max2=125;

int max3=175;

public void doMenu() throws Exception

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("5.Display unbooked tickets");

System.out.println("6.Exit");

System.out.println("Please enter your choice");

cho=Integer.parseInt(br.readLine());

switch(cho)

case 1: doBook(); break;

case 2: doCancel(); break;

case 3: doSearch(); break;

case 4: doDispList(); break;

case 5: doDispUnbooked(); break;

case 6: doExit(); break;

default : System.out.println("Invalid choice");

}
char e=(char)br.read();

}while(cho!=6);

private void doHeading()throws Exception

System.out.println("########################################
#################");

System.out.println("****** Railway Reservation For Geetanjali


Express *******");

System.out.println("########################################
#################");

private void doBook()throws Exception

System.out.println("Please enter the class of ticket");

System.out.println("1. AC\t 2. First\t 3. Sleeper\t");

int c=Integer.parseInt(br.readLine());

System.out.println("Please enter no. of tickets");

int t=Integer.parseInt(br.readLine());

int ticketAvailable=0;

if(c==1 && max1>=t)


{

ticketAvailable=1;

if(c==2 && max2>=t)

ticketAvailable=1;

if(c==3 && max3>=t)

ticketAvailable=1;

if(ticketAvailable==1)

for(int i=0;i<t;i++)

pno[pcount]=pnum;

System.out.println("Please enter your name");

name[pcount]=br.readLine();

System.out.println("Please enter your age");

age[pcount]=Integer.parseInt(br.readLine());

cl[pcount]=c;
System.out.println("Please enter your phno");

phno[pcount]=br.readLine();

pcount++;

pnum++;

System.out.println("Ticket successfully booked");

}//for

if(c==1)

max1-=t;

System.out.println("Please pay Rs."+t*1500);

if(c==2)

max2-=t;

System.out.println("Please pay Rs."+t*1200);

if(c==3)

max3-=t;

System.out.println("Please pay Rs."+t*1000);

}
}

private void doCancel()throws Exception

int t_pno[]=new int[275];

String t_name[]=new String[275];

String t_phno[]=new String[275];

int t_age[]=new int[275];

int t_cl[]=new int[275];

int t_pcount=0;

int passengerFound=0;

System.out.println("Please enter your passenger no.");

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++;

System.out.println("Please collect refund of Rs."+1800);

if(cl[i]==2)

max2++;

System.out.println("Please collect refund of Rs."+1500);

if(cl[i]==3)

max3++;

System.out.println("Please collect refund of Rs."+1000);

}//else
}//if

if(passengerFound==1)

pno=t_pno;

name=t_name;

age=t_age;

cl=t_cl;

phno=t_phno;

pcount=t_pcount;

System.out.println("ticket successfully cancelled");

}//method

private void doDispList()throws Exception

System.out.println("Passenger list in AC class");

System.out.println("pno \t name \t\t age \t phno");

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]);

System.out.println("Passenger list in First class");

System.out.println("pno \t name \t\t age \t phno");

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]);

System.out.println("Passenger list in Sleeper class");

System.out.println("pno \t name \t\t age \t phno");

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]);

}
}

private void doSearch()throws Exception

int passengerFound=0;

System.out.println("Please enter passenger no. to search");

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("No such passenger");


}//method

private void doDispUnbooked()throws Exception

System.out.println("No. of booked tickets status");

System.out.println("AC class"+max1);

System.out.println("First class"+max2);

System.out.println("Sleeper class"+max3);

private void doExit()

System.out.println("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&&&&&&&");

System.out.println("Name : Prathamesh , Class : X, Roll No. : 22");

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;

public class Calender extends JPanel

{
protected int yy;

protected int mm, dd;

/** The buttons to be displayed */

protected JButton labs[][];

/** The number of day squares to leave blank at the start of this
month */

protected int leadGap = 0;

/** A Calendar object used throughout */

Calendar calendar = new GregorianCalendar();

/** Today's year */

protected final int thisYear = calendar.get(Calendar.YEAR);

/** Today's month */

protected final int thisMonth = calendar.get(Calendar.MONTH);

/** One of the buttons. We just keep its reference for


getBackground(). */

private JButton b0;


/** The month choice */

private JComboBox monthChoice;

/** The year choice */

private JComboBox yearChoice;

/**

* Construct a Cal, starting with today.

*/

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

* If year out of range

*/

Calender(int year, int month, int today)

super();

setYYMMDD(year, month, today);

buildGUI();

recompute();

private void setYYMMDD(int year, int month, int today)

yy = year;

mm = month;

dd = today;

String[] months = { "January", "February", "March", "April", "May",


"June",
"July", "August", "September", "October", "November",
"December" };

/** Build the GUI. Assumes that setYYMMDD has been called. */

private void buildGUI()

getAccessibleContext().setAccessibleDescription(

"Calendar not accessible yet. Sorry!");

setBorder(BorderFactory.createEtchedBorder());

setLayout(new BorderLayout());

JPanel tp = new JPanel();

tp.add(monthChoice = new JComboBox());

for (int i = 0; i < months.length; i++)

monthChoice.addItem(months[i]);

monthChoice.setSelectedItem(months[mm]);

monthChoice.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent ae)

int i = monthChoice.getSelectedIndex();
if (i >= 0) {

mm = i;

// System.out.println("Month=" + mm);

recompute();

});

monthChoice.getAccessibleContext().setAccessibleName("Months");

monthChoice.getAccessibleContext().setAccessibleDescription(

"Choose a month of the year");

tp.add(yearChoice = new JComboBox());

yearChoice.setEditable(true);

for (int i = yy - 5; i < yy + 5; i++)

yearChoice.addItem(Integer.toString(i));

yearChoice.setSelectedItem(Integer.toString(yy));

yearChoice.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent ae)

int i = yearChoice.getSelectedIndex();
if (i >= 0) {

yy = Integer.parseInt(yearChoice.getSelectedItem()

.toString());

//System.out.println("Year=" + yy);

recompute();

});

add(BorderLayout.CENTER, tp);

JPanel bp = new JPanel();

bp.setLayout(new GridLayout(7, 7));

labs = new JButton[6][7]; // first row is days

bp.add(b0 = new JButton("S"));

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()

public void actionPerformed(ActionEvent e)

String num = e.getActionCommand();

if (!num.equals(""))

// set the current day highlighted

setDayActive(Integer.parseInt(num));

// When this becomes a Bean, you can

// fire some kind of DateChanged event here.

// Also, build a similar daySetter for day-of-week btns.

};

// Construct all the buttons, and add them.

for (int i = 0; i < 6; i++)

for (int j = 0; j < 7; j++) {

bp.add(labs[i][j] = new JButton(""));


labs[i][j].addActionListener(dateSetter);

add(BorderLayout.SOUTH, bp);

public final static int dom[] = { 31, 28, 31, 30,31, 30, 31, 31,30, 31,
30, 31};

/** Compute which days to put where, in the Cal panel */

protected void recompute()

// System.out.println("Cal::recompute: " + yy + ":" + mm + ":" +


dd);

if (mm < 0 || mm > 11)

throw new IllegalArgumentException("Month " + mm

+ " bad, must be 0-11");

clearDayActive();

calendar = new GregorianCalendar(yy, mm, dd);

// Compute how much to leave before the first.

// getDay() returns 0 for Sunday, which is just right.


leadGap = new GregorianCalendar(yy, mm,
1).get(Calendar.DAY_OF_WEEK) - 1;

// System.out.println("leadGap = " + leadGap);

int daysInMonth = dom[mm];

if (isLeap(calendar.get(Calendar.YEAR)) && mm > 1)

++daysInMonth;

// Blank out the labels before 1st day of month

for (int i = 0; i < leadGap; i++) {

labs[0][i].setText("");

// Fill in numbers for the day of month.

for (int i = 1; i <= daysInMonth; i++) {

JButton b = labs[(leadGap + i - 1) / 7][(leadGap + i - 1) % 7];

b.setText(Integer.toString(i));

// 7 days/week * up to 6 rows

for (int i = leadGap + 1 + daysInMonth; i < 6 * 7; i++) {

labs[(i) / 7][(i) % 7].setText("");


}

// Shade current day, only if current month

if (thisYear == yy && mm == thisMonth)

setDayActive(dd); // shade the box for today

// Say we need to be drawn on the screen

repaint();

/**

* isLeap() returns true if the given year is a Leap Year.

* "a year is a leap year if it is divisible by 4 but not by 100, except

* that years divisible by 400 *are* leap years." -- Kernighan &


Ritchie,

* _The C Programming Language_, p 37.

*/

public boolean isLeap(int year)

if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)

return true;
return false;

/** Set the year, month, and day */

public void setDate(int yy, int mm, int dd)

// System.out.println("Cal::setDate");

this.yy = yy;

this.mm = mm; // starts at 0, like Date

this.dd = dd;

recompute();

/** Unset any previously highlighted day */

private void clearDayActive()

JButton b;

// First un-shade the previously-selected square, if any

if (activeDay > 0)

b = labs[(leadGap + activeDay - 1) / 7][(leadGap + activeDay - 1) %


7];
b.setBackground(b0.getBackground());

b.repaint();

activeDay = -1;

private int activeDay = -1;

/** Set just the day, on the current month */

public void setDayActive(int newDay)

clearDayActive();

// Set the new one

if (newDay <= 0)

dd = new GregorianCalendar().get(Calendar.DAY_OF_MONTH);

else

dd = newDay;

// Now shade the correct square

Component square = labs[(leadGap + newDay - 1) / 7][(leadGap +


newDay - 1) % 7];

square.setBackground(Color.red);

square.repaint();
activeDay = newDay;

/** For testing, a main program */

public static void main(String[] av)

JFrame f = new JFrame("Calender");

Container c = f.getContentPane();

c.setLayout(new FlowLayout());

// for this test driver, hardcode 1995/02/10.

// c.add(new Calender(1995, 2 - 1, 10));

// and beside it, the current month.

c.add(new Calender());

f.pack();

f.setVisible(true);

You might also like