Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 32

THE PROGRAM : SCIENCE QUIZ

import java.io.*;
class Quiz
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int cap = 0;int cac = 0;String name = "";String word = "";int i = 0;char ch;int cab = 0;String nam="";
String scho1="";String scho2="";char sub = ' ';
int menu1() throws IOException
{
boolean m1=true;
while(m1)
{
System.out.println(" HERE ARE THE OPTIONS:");System.out.println();
System.out.println("1. PLAY THE QUIZ");
System.out.println("2. THE RULES");
System.out.println("3. CREDITS");
System.out.println("4. EXIT");System.out.println();System.out.println("Make your choice...!!!");
System.out.println();
scho1=br.readLine();
char fch = scho1.charAt(0);
if (( fch=='1')||(fch=='2')||(fch=='3')||(fch=='4'))
{
break;
}
else
{
System.out.println("\n Oop's...!!! Wrong input, Try again.");
continue;
}
}
int cho1 = Integer.parseInt(scho1);
System.in.skip(System.in.available());return cho1;
} // end of menu1
int menu2() throws IOException
{
System.in.skip(System.in.available());
boolean m2=true;
while(m2)
{

1
System.out.println(" YOU HAVE CHOSEN 1. PLAY THE QUIZ");System.out.println();
System.out.println(" Now you have a choice here " + nam );
System.out.println(" You may either choose to play a SINGLE SUBJECT QUIZ or opt for a
COMPLETE 3-SUBJECT QUIZ");
System.out.println(" Type 1 for SINGLE SUBJECT QUIZ");
System.out.println(" Type 2 for COMPLETE 3-SUBJECT QUIZ");System.out.println();
System.out.println(" The choice is yours...!!!");System.out.println();
scho2=br.readLine();
char fch1 = scho2.charAt(0);
if (( fch1=='1')||(fch1=='2'))
{
break;
}
else
{
System.out.println("\n Oop's...!!! Wrong input, Try again.");
continue;
}
}// end of while

int cho2 = Integer.parseInt(scho2);


System.in.skip(System.in.available());return cho2;
} // end of menu2
char menu3() throws IOException
{
boolean m3=true;
while(m3)
{
System.out.println(" YOU HAVE CHOSEN 1. SINGLE SUBJECT QUIZ ");System.out.println();
System.out.println(" Now select your subject - PHYSICS , CHEMISTRY , BIOLOGY");
System.out.println(" Type 'P' for PHYSICS");
System.out.println(" Type 'C' for CHEMISTRY");
System.out.println(" Type 'B' for BIOLOGY");System.out.println();
sub = (char)System.in.read();
if (( sub=='P')||(sub=='C')||(sub=='B')||( sub=='p')||(sub=='c')||(sub=='b'))
{
break;
}
else
{

2
System.out.println("\n Oop's...!!! Wrong input, Try again.");
continue;
}
}
System.in.skip(System.in.available());return sub;
}
void welcome()
{
System.out.println(" WELCOME");
System.out.println();

System.out.println("***************************************************_______********************************
*******************");
System.out.println(" ICSE COMPUTER PROJECT");
System.out.println(" 2014 - 2015");
System.out.println("--------------------------------------------------------------------------------------------------------
-----");
System.out.println();
System.out.println(" SCIENCE QUIZ");
System.out.println(" [FOR CLASS-X]");

System.out.println("+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+_____________+*+*+*+*+*+
*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+");
}
void rules()
{
System.out.println(" YOU HAVE CHOSEN 2. THE RULES");
System.out.println();System.out.println(" THE RULES");System.out.println();
System.out.println(" 1. The science quiz for class X ICSE students offer choice to the user to
choose between three science");
System.out.println(" subjects namely Physics, Chemistry and Biology.");
System.out.println(" 2. The user can opt either to play a SINGLE SUBJECT QUIZ (...and choose
to play based on choice of subject)");
System.out.println(" or a COMPLETE 3-SUBJECT QUIZ (...follow the general sequence of
Physics, Chemistry and Biology).");
System.out.println(" 3. For every question, the user is asked to make his/her choice of the correct
answer (choose from 4 displayed options).");
System.out.println(" 4. For every subject, the user gets to answer five questions and for every
correct choice, he/she is awarded 2 marks.");

3
System.out.println(" 5. At the end, a 'Grade Sheet' is displayed with the user's score and other
information.");
System.out.println();
}
void credits()
{

System.out.println("******************************************************ABOUT******************************
************************");
System.out.println();
System.out.println(" The science quiz project was developed as part of the ICSE Computer
applications course for the year 2014-15.");
System.out.println("It was developed and programmed in Java (version 3.1.1) by K.Sashank and
Harshit Motiwala.");
System.out.println("The program has following components: Name identification, subject choice,
rules and credits, marking and ");
System.out.println("tracking questions answered correctly, grade card making and display etc.");
System.out.println();

System.out.println("**************************************************ACKNOWLEDGEMENTS**************
**********************************");
System.out.println();
System.out.println(" It is a great pleasure to thank those who helped us completing this project
work. Firstly, we owe");
System.out.println(" our deepest gratitude to our teacher, Ms. Nandita Pattanayak, Loyola School,
Bhubaneswar. We are grateful");
System.out.println(" for her valuable guidance, training and encouragement to complete this
project. On a personal note, we");
System.out.println(" would like to thank our parents, who encouraged us in all possible ways
without which we");
System.out.println(" would not have made it across the finishing line.");System.out.println();
System.out.println(" Last but not least, we thank the almighty who gave us the strength and
perseverance to complete this work.");
System.out.println();

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

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

void interact() throws IOException


{
System.out.println(" PLEASE ENTER YOUR FULL NAME");
name = br.readLine();
int l = name.length();
name = name.trim();
name = name + " ";
for ( i = 0 ; i <= l ; i++)
{
ch = name.charAt(i);
if( ch == ' ' )
{
break;
}
else
{
word = word + ch;
}
}
nam = word;
word = "";System.out.println(" Hi " + nam + "...!!! LET'S GET STARTED.");
}// to get the first name of the user

int physics() throws IOException


{
cap=0;

System.out.println("==============================================================
=====================");
System.out.println(" PHYSICS QUESTIONS ");
System.out.println();System.out.println();
System.out.println("Q1 Name the energy transformation that occurs in a nuclear reactor.");
System.out.println();
System.out.println(" A. nuclear mass to heat energy B. nuclear mass to light energy ");

5
System.out.println(" C. nuclear energy to sound energy D. electrical energy to heat
energy");
System.out.println();char ansp1 = (char)System.in.read();
System.out.println("Your Answer : " + ansp1 );
if(( ansp1 == 'A' ) || ( ansp1 == 'a' ))
{
System.out.println("That's the right answer ...!!! You get 2 points.");
cap = cap + 1;

System.out.println();
}
else
{
System.out.println("Oop's! You've got this one wrong.");cap = cap + 0;
System.out.println("The correct answer is A. nuclear mass to heat energy
");System.out.println();System.out.println("You get 0 points.");
System.out.println();
}
System.in.skip(System.in.available());
System.out.println("Q2 If an object is placed at focus F1, in front of a convex lens ");
System.out.println(" and the image formed is real, inverted and highly enlarged, then");
System.out.println(" the position of the image is at ...");
System.out.println();
System.out.println(" A. at focus F2 B. at 2F2");
System.out.println(" C. at infinity D. between F2 and 2F2");
System.out.println();char ansp2 = (char)System.in.read();
System.out.println("Your Answer : " + ansp2 );
if(( ansp2 == 'C' )||( ansp2 == 'c' ))
{
System.out.println("That's the right answer ...!!! You get 2 points.");
cap = cap + 1;

System.out.println();
}
else
{
System.out.println("Oop's! You've got this one wrong.");cap = cap + 0;System.out.println("The
correct answer is C. at infinity ");
System.out.println();System.out.println("You get 0 points.");System.out.println();

6
System.out.println();
}
System.in.skip(System.in.available());
System.out.println("Q3 What parameter does not change when a ray of light undergoes
refraction? ");
System.out.println();
System.out.println(" A. Wavelength B. Speed");
System.out.println(" C. Direction D. Frequency");
System.out.println();char ansp3 = (char)System.in.read();
System.out.println("Your Answer : " + ansp3 );
if(( ansp3 == 'D' )||( ansp3 == 'd' ))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cap = cap + 1;

System.out.println();
}
else
{
System.out.println(" Oop's! You've got this one wrong.");cap = cap + 0;
System.out.println(" The correct answer is D. Frequency ");System.out.println();
System.out.println("You get 0 points.");System.out.println();
}
System.in.skip(System.in.available());
System.out.println("Q4 Due to repeated reflections at the reflecting surface (as in tombs like the
");
System.out.println(" Taj Mahal , Sikandra), the sound gets prolonged...");
System.out.println(" The effect is known as __________");
System.out.println();
System.out.println(" A. Echo B. Reverberation");
System.out.println(" C. Resonance D. Free Vibrations");
System.out.println();char ansp4 = (char)System.in.read();
System.out.println("Your Answer : " + ansp4 );
if(( ansp4 == 'B' )||( ansp4 == 'b' ))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cap = cap + 1;

System.out.println();
}

7
else
{
System.out.println(" Oop's! You've got this one wrong.");cap = cap + 0;System.out.println("
The correct answer is B. Reverberation ");
System.out.println();System.out.println("You get 0 points.");
System.out.println();
}
System.in.skip(System.in.available());
System.out.println("Q5 A fuse wire is made up of an alloy of lead and tin because it has ... ");
System.out.println();
System.out.println(" A. high resistivity and low melting point B. low resistivity and high melting
point");
System.out.println(" C. high resistivity and high melting point D. low resistivity and low melting
point");
System.out.println();char ansp5 = (char)System.in.read();
System.out.println(" Your Answer : " + ansp5 );
if(( ansp5 == 'A' )||( ansp5 == 'a'))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cap = cap + 1;
System.out.println();
}
else
{
System.out.println(" Oop's! You've got this one wrong.");cap = cap + 0;
System.out.println(" The correct answer is A. high resistivity and low melting point
");System.out.println();System.out.println("You get 0 points.");
System.out.println();
}

return cap ;

}// Physics module

int chemistry () throws IOException


{
cac=0;

8
System.in.skip(System.in.available());System.out.println("=================================
==================================================");
System.out.println(" CHEMISTRY QUESTIONS");
System.out.println();System.out.println();
System.out.println("Q1 Which of the following is a common characteristics of a covalent
compound?");
System.out.println();
System.out.println(" A. High melting point B. Conduct electricity in molten state ");
System.out.println(" C. Consists of molecules D. Always soluble in water");
System.out.println();char ansc1 = (char)System.in.read();
System.out.println(" Your Answer : " + ansc1 );
if(( ansc1 == 'C' ) || ( ansc1 == 'c' ))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cac = cac + 1;

System.out.println();
}
else
{
System.out.println(" Oop's! You've got this one wrong.");cac = cac + 0;

System.out.println(" The correct answer is C. Consists of molecules


");System.out.println();System.out.println("You get 0 points.");System.out.println();
}
System.in.skip(System.in.available());
System.out.println("Q2 Duralumin is an alloy of...");
System.out.println();
System.out.println(" A. Al and Cu B. Cu and Sn");
System.out.println(" C. Al and Ag D. Al and Fe");
System.out.println();char ansc2 = (char)System.in.read();
System.out.println(" Your Answer : " + ansc2 );
if (( ansc2 == 'A' ) || ( ansc2 == 'a'))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cac = cac + 1;
System.out.println();
}
else

9
{
System.out.println(" Oop's! You've got this one wrong.");cac = cac + 0;
System.out.println(" The correct answer is A. Al and Cu
");System.out.println();System.out.println("You get 0 points.");
System.out.println();
}
System.in.skip(System.in.available());
System.out.println("Q3 Formation of chloroform from methane and chlorine is an example of...");
System.out.println();
System.out.println(" A. Addition B. Dehydration");
System.out.println(" C. Sustitution D. Elimination");
System.out.println();char ansc3 = (char)System.in.read();
System.out.println(" Your Answer : " + ansc3 );
if (( ansc3 == 'C' ) || ( ansc3 == 'c'))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cac = cac + 1;
System.out.println();
}
else
{
System.out.println(" Oop's! You've got this one wrong.");cac = cac + 0;
System.out.println(" The correct answer is c. Sustitution
");System.out.println();System.out.println("You get 0 points.");
System.out.println();
}
System.in.skip(System.in.available());
System.out.println("Q4 During the electrolysis of acidified water which of the following takes");
System.out.println(" place?");
System.out.println();
System.out.println(" A. Oxygen is released at cathode B. Oxygen is released at anode");
System.out.println(" C. Hydrogen is released at anode D. Sulphur Dioxide is released at
anode");
System.out.println();char ansc4 = (char)System.in.read();
System.out.println(" Your Answer : " + ansc4 );
if (( ansc4 == 'B' ) || ( ansc4 == 'b'))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cac = cac + 1;
System.out.println();

10
}
else
{
System.out.println(" Oop's! You've got this one wrong.");cac = cac + 0;
System.out.println(" The correct answer is B. Oxygen is released at
anode");System.out.println();System.out.println("You get 0 points.");
System.out.println();
}
System.in.skip(System.in.available());
System.out.println("Q5 The Gas law which relates the volume of gas to moles of the gas is ... ");
System.out.println();
System.out.println(" A. Avagadro's Law B. Gay-Lussac's Law");
System.out.println(" C. Boyle's Law D. Charles Law");
System.out.println();char ansc5 = (char)System.in.read();
System.out.println(" Your Answer : " + ansc5 );
if (( ansc5 == 'A' ) || ( ansc5 == 'a'))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cac = cac + 1;
System.out.println();
}
else
{
System.out.println(" Oop's! You've got this one wrong.");cac = cac + 0;
System.out.println(" The correct answer is A. Avagadro's Law
");System.out.println();System.out.println("You get 0 points.");
System.out.println();
}

return cac ;

}//Chemistry module

int biology () throws IOException


{
cab=0;

System.in.skip(System.in.available());System.out.println("=================================
==================================================");

11
System.out.println(" BIOLOGY QUESTIONS");
System.out.println();System.out.println();
System.out.println("Q1 Cytokinesis occurs in which phase of mitosis?");
System.out.println();
System.out.println(" A. Prophase B. Metaphase ");
System.out.println(" C. Anaphase D. Telophase");
System.out.println();char ansb1 = (char)System.in.read();
System.out.println(" Your Answer : " + ansb1 );
if (( ansb1 == 'D' ) || ( ansb1 == 'd'))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cab = cab + 1;
System.out.println();
}
else
{
System.out.println(" Oop's! You've got this one wrong.");cab = cab + 0;

System.out.println(" The correct answer is D. Telophase


");System.out.println();System.out.println("You get 0 points.");System.out.println();
}
System.in.skip(System.in.available());
System.out.println("Q2 Choose the correct sequence -");
System.out.println();
System.out.println(" A. Xylem,phloem,endodermis,cortex,epidermis,root hair");
System.out.println(" B. Xylem,phloem,cortex,epidermis,endodermis,root hair");
System.out.println(" C. Phloem,xylem,cortex,root hair,epidermis,endodermis");
System.out.println(" D. Xylem,phloem,cortex,epidermis,root hair,endodermis");
System.out.println();char ansb2 = (char)System.in.read();
System.out.println(" Your Answer : " + ansb2 );
if (( ansb2 == 'A' ) || ( ansb2 == 'a'))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cab = cab + 1;
System.out.println();
}
else
{
System.out.println(" Oop's! You've got this one wrong.");cab = cab + 0;

12
System.out.println(" The correct answer is A. Xylem,phloem,endodermis,cortex,epidermis,root
hair ");System.out.println();System.out.println("You get 0 points.");
System.out.println();
}
System.in.skip(System.in.available());
System.out.println("Q3 Give the full form of NADP.");
System.out.println();
System.out.println(" A. Nicotine Alkaline Diphosphoric Prophase B. Nicotinamide Adenine
Dinucleotide Phosphate");
System.out.println(" C. Nickel Adenosine Dinucleotide Pentane D. None of the above");
System.out.println();char ansb3 = (char)System.in.read();
System.out.println(" Your Answer : " + ansb3 );
if (( ansb3 == 'B' ) || ( ansb3 == 'b'))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cab = cab + 1;
System.out.println();
}
else
{
System.out.println(" Oop's! You've got this one wrong.");cab = cab + 0;
System.out.println(" The correct answer is B. Nicotinamide Adenine Dinucleotide Phosphate
");System.out.println();System.out.println("You get 0 points.");
System.out.println();
}
System.in.skip(System.in.available());
System.out.println("Q4 Which is the region of the best vision in a human eye ?");
System.out.println();
System.out.println(" A. Blind spot B. Uterus");
System.out.println(" C. Yellow spot D. Cornea");
System.out.println();char ansb4 = (char)System.in.read();
System.out.println(" Your Answer : " + ansb4 );
if (( ansb4 == 'C' ) || ( ansb4 == 'c'))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cab = cab + 1;
System.out.println();
}
else
{

13
System.out.println(" Oop's! You've got this one wrong.");cab = cab + 0;
System.out.println(" The correct answer is c. Yellow
spot");System.out.println();System.out.println("You get 0 points.");
System.out.println();
}
System.in.skip(System.in.available());
System.out.println("Q5 A secretion of Basophil cells which is an anti-coagulant. ");
System.out.println();
System.out.println(" A. Histamine B. Heparin");
System.out.println(" C. Cortisone D. Calcitonin ");
System.out.println();char ansb5 = (char)System.in.read();
System.out.println(" Your Answer : " + ansb5 );
if (( ansb5 == 'B' ) || ( ansb5 == 'b'))
{
System.out.println(" That's the right answer ...!!! You get 2 points.");
cab = cab + 1;
System.out.println();
}
else
{
System.out.println(" Oop's! You've got this one wrong.");cab = cab + 0;
System.out.println(" The correct answer is B. Heparin
");System.out.println();System.out.println("You get 0 points.");
System.out.println();
}

return cab ;

}// Biology module

void display (int x , String subj1 , int co)


{
int atmp;System.out.println();

System.out.println("==============================================================
=============================================");
System.out.println();
int sc = x * 2 ;
System.out.println(" THE GRADE SHEET");

14
System.out.println(" NAME - " + name );
System.out.println();
if( co == 5 )
{

System.out.println(" SINGLE SUBJECT QUIZ CHOSEN");


System.out.println(" SUBJECT CHOSEN - " + subj1 );
System.out.println();
}

if( co == 15 )
{
System.out.println(" ALL ( 3 ) SUBJECT QUIZ CHOSEN");
}
System.out.println();
if( co == 5 && x == 0 )
{
System.out.println(" NUMBER OF QUESTIONS ATTEMPTED = " + co );
System.out.println(" NUMBER OF QUESTIONS ANSWERED CORRECTLY = " + x );
System.out.println();
System.out.println(" SCORE = " + sc );
System.out.println(" YOUR GRADE - F");
System.out.println();System.out.println(" You really need to work hard . Start now");
}
if( co == 5 && sc > 0 && sc <= 2 )
{
System.out.println(" NUMBER OF QUESTIONS ATTEMPTED = " + co );
System.out.println(" NUMBER OF QUESTIONS ANSWERED CORRECTLY = " + x );
System.out.println();
System.out.println(" SCORE = " + sc );
System.out.println(" YOUR GRADE - E");
System.out.println();System.out.println(" Improvement needed . Keep going ...!!!");
}
if( co == 5 && sc > 2 && sc <= 4 )
{
System.out.println(" NUMBER OF QUESTIONS ATTEMPTED = " + co );
System.out.println(" NUMBER OF QUESTIONS ANSWERED CORRECTLY = " + x );
System.out.println();
System.out.println(" SCORE = " + sc );
System.out.println(" YOUR GRADE - D");

15
System.out.println();System.out.println(" Work harder ...!!!");
}
if( co == 5 && sc > 4 && sc <= 7 )
{
System.out.println(" NUMBER OF QUESTIONS ATTEMPTED = " + co );
System.out.println(" NUMBER OF QUESTIONS ANSWERED CORRECTLY = " + x );
System.out.println();
System.out.println(" SCORE = " + sc );
System.out.println(" YOUR GRADE - C");
System.out.println();System.out.println(" Satisfactory! You can do better with more effort !!");
}
if( co == 5 && sc > 7 && sc <= 8 )
{
System.out.println(" NUMBER OF QUESTIONS ATTEMPTED = " + co );
System.out.println(" NUMBER OF QUESTIONS ANSWERED CORRECTLY = " + x );
System.out.println();
System.out.println(" SCORE = " + sc );
System.out.println(" YOUR GRADE - B");
System.out.println();System.out.println(" Good. Perfection needed.");
}
if( co == 5 && sc > 8 && sc <= 10 )
{
System.out.println(" NUMBER OF QUESTIONS ATTEMPTED = " + co );
System.out.println(" NUMBER OF QUESTIONS ANSWERED CORRECTLY = " + x );
System.out.println();
System.out.println(" SCORE = " + sc );
System.out.println(" YOUR GRADE - A");
System.out.println();System.out.println(" Very Good !!! Keep it up !");
}
if( co == 15 && sc >= 0 && sc <= 5 )
{
System.out.println(" NUMBER OF QUESTIONS ATTEMPTED = " + co );
System.out.println(" NUMBER OF QUESTIONS ANSWERED CORRECTLY = " + x );
System.out.println();
System.out.println(" SCORE = " + sc );
System.out.println(" YOUR GRADE - F");
System.out.println();System.out.println(" You really need to work hard. Start now");
}
if( co == 15 && sc > 5 && sc <= 10 )
{

16
System.out.println(" NUMBER OF QUESTIONS ATTEMPTED = " + co );
System.out.println(" NUMBER OF QUESTIONS ANSWERED CORRECTLY = " + x );
System.out.println();
System.out.println(" SCORE = " + sc );
System.out.println(" YOUR GRADE - E");
System.out.println();System.out.println(" Improvement needed. Keep going ...!!!");
}
if( co == 15 && sc > 10 && sc <= 15 )
{
System.out.println(" NUMBER OF QUESTIONS ATTEMPTED = " + co );
System.out.println(" NUMBER OF QUESTIONS ANSWERED CORRECTLY = " + x );
System.out.println();
System.out.println(" SCORE = " + sc );
System.out.println(" YOUR GRADE - D");
System.out.println();System.out.println(" Work harder ...!!!");
}
if( co == 15 && sc > 15 && sc <= 20 )
{
System.out.println(" NUMBER OF QUESTIONS ATTEMPTED = " + co );
System.out.println(" NUMBER OF QUESTIONS ANSWERED CORRECTLY = " + x );
System.out.println();
System.out.println(" SCORE = " + sc );
System.out.println(" YOUR GRADE - C");
System.out.println();System.out.println(" Satisfactory! You can do better with more effort!!");
}
if( co == 15 && sc > 20 && sc <= 25 )
{
System.out.println(" NUMBER OF QUESTIONS ATTEMPTED = " + co );
System.out.println(" NUMBER OF QUESTIONS ANSWERED CORRECTLY = " + x );
System.out.println();
System.out.println(" SCORE = " + sc );
System.out.println(" YOUR GRADE - B");
System.out.println();System.out.println(" Good. Perfection needed.");
}
if( co == 15 && sc > 25 && sc <= 30 )
{
System.out.println(" NUMBER OF QUESTIONS ATTEMPTED = " + co );
System.out.println(" NUMBER OF QUESTIONS ANSWERED CORRECTLY = " + x );
System.out.println();
System.out.println(" SCORE = " + sc );

17
System.out.println(" YOUR GRADE - A");
System.out.println();System.out.println(" Very Good !!! Keep it up !");
}
System.out.println();

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

public static void main(String[] arg) throws IOException// the main method
{
BufferedReader mbr = new BufferedReader(new InputStreamReader(System.in));
{
String mstr=""; String mstr2="";
Quiz obj = new Quiz();
int j = 0;int subco;int co = 0;String subj = "";int ca = 0;
boolean b1=true;
obj.welcome();
obj.interact();
out:
while(b1)
{
int x = obj.menu1();
boolean b2=true;
in:
while(b2)
{
if (x==1)
{
boolean b3=true;
while(b3)
{

int y = obj.menu2();
{
if (y==1)
{
char s = obj.menu3();
if (( s == 'P' )||( s == 'p' ))

18
{
ca = obj.physics();co = 5;
subj = "PHYSICS";
}
if (( s == 'C' )||( s == 'c' ))
{
ca = obj.chemistry();co = 5;
subj = "CHEMISTRY";
}
if (( s == 'B' )||( s == 'b' ))
{
ca = obj.biology();co = 5;
subj = "BIOLOGY";
}

obj.display( ca , subj , co );
boolean b4=true;
while(b4)
{
System.out.println(" Type 1 for Exit ");
System.out.println(" Type 2 to Continue ");
System.in.skip(System.in.available());
mstr=mbr.readLine();
char mch = mstr.charAt(0);
if (( mch=='1')||(mch=='2'))
{
break;
}
else
{
System.out.println("\n Oop's...!!! Wrong input, Try again.");
continue;
}
} //end of while b4
int q=Integer.parseInt(mstr);

switch(q)
{
case 1:
{

19
break out;
}
case 2:
{
break in;
}
}
}//end Y=1

if ( y == 2 )
{
int m1 = obj.physics();
int m2 = obj.chemistry();
int m3 = obj.biology();
ca = m1 + m2 + m3;co = 15;
obj.display( ca , subj , co );
boolean b5=true;
while(b5)
{
System.out.println();
System.out.println(" Type 1 for Exit ");
System.out.println(" Type 2 to Continue "); System.out.println();
System.in.skip(System.in.available());
mstr2=mbr.readLine();
char mch2 = mstr2.charAt(0);
if (( mch2=='1')||(mch2=='2'))
{
break;
}
else
{
System.out.println("\n Oop's...!!! Wrong input, Try again.");
continue;
}
} //end of while b5

int q=Integer.parseInt(mstr2);
switch(q)
{
case 1:

20
{
break out;
}
case 2:
{
break in;
}
}
}//end Y=2
}//end Y
}//end while b3
}//end X=1
if ( x == 2 )
{
obj.rules();
break;
}
if ( x == 3 )
{
obj.credits();
break;
}
if ( x == 4 )
{
break out;
}
}//end while b2 & in
}// end while b1 & out
}//end mbr
System.out.println(" ***THANK YOU...!!!***");System.out.println();
System.out.println(" Program developed by K.Sashank and H.Motiwala");
System.out.println();System.out.println();
System.out.println(" ~~JAVA~~ ");
}//end of main
}//end of class

21
DOCUMENTATION

Class Quiz
java.lang.Object

Quiz

class Quizextends java.lang.Object

Field Summary

(package private) br
java.io.BufferedReader

(package private) int cab

(package private) int cac

(package private) int cap

(package private) char ch

(package private) int i

(package private) nam


java.lang.String

(package private) name


java.lang.String

(package private) scho1


java.lang.String

(package private) scho2


java.lang.String

(package private) char sub

(package private) word


java.lang.String

22
Constructor Summary

Quiz()

Method Summary

(package biology()
private) int

(package chemistry()
private) int

(package credits()
private) void

(package display(int x, java.lang.String subj1, int co)


private) void

(package interact()
private) void

static void main(java.lang.String[] arg)

(package menu1()
private) int

(package menu2()
private) int

(package menu3()
private) char

(package physics()
private) int

(package rules()
private) void

(package welcome()
private) void

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

23
Field Detail

br
java.io.BufferedReader br

cab
int cab

cac
int cac

cap
int cap

ch
char ch

i
int i

nam
java.lang.String nam

name
java.lang.String name

scho1
java.lang.String scho1

scho2
java.lang.String scho2

sub
char sub

word
java.lang.String word

Constructor Detail

24
Quiz
Quiz()

Method Detail

biology
int biology()
throws java.io.IOException
Throws:
java.io.IOException

chemistry
int chemistry()
throws java.io.IOException
Throws:
java.io.IOException

credits
void credits()

display
void display(int x,
java.lang.String subj1,
int co)

interact
void interact()
throws java.io.IOException
Throws:
java.io.IOException

main
public static void main(java.lang.String[] arg)
throws java.io.IOException
Throws:
java.io.IOException

menu1
int menu1()
throws java.io.IOException
Throws:

25
java.io.IOException

menu2
int menu2()
throws java.io.IOException
Throws:
java.io.IOException

menu3
char menu3()
throws java.io.IOException
Throws:
java.io.IOException

physics
int physics()
throws java.io.IOException
Throws:
java.io.IOException

rules
void rules()

welcome
void welcome()

AN EXAMPLE OF THE OUTPUT

WELCOME

***************************************************_______***************************************************
ICSE COMPUTER PROJECT
2014 - 2015
-------------------------------------------------------------------------------------------------------------

SCIENCE QUIZ
[FOR CLASS-X]

26
+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*++*+*+*+*+*+_____________+*+*+*+*+*+*+*+*+*+*+*+*+*+*+
*+*+*+*++*+*+*+*+*+
PLEASE ENTER YOUR FULL NAME
Sashank Kali
Hi Sashank...!!! LET'S GET STARTED.
HERE ARE THE OPTIONS:

1. PLAY THE QUIZ


2. THE RULES
3. CREDITS
4. EXIT

Make your choice...!!!


2
YOU HAVE CHOSEN 2. THE RULES

THE RULES

1. The science quiz for class X ICSE students offer choice to the user to choose between three
science
subjects namely Physics, Chemistry and Biology.
2. The user can opt either to play a SINGLE SUBJECT QUIZ (...and choose to play based on choice
of subject)
or a COMPLETE 3-SUBJECT QUIZ (...follow the general sequence of Physics, Chemistry and
Biology).
3. For every question, the user is asked to make his/her choice of the correct answer (choose from 4
displayed options).
4. For every subject, the user gets to answer five questions and for every correct choice, he/she is
awarded 2 marks.
5. At the end, a 'Grade Sheet' is displayed with the user's score and other information.

HERE ARE THE OPTIONS:

1. PLAY THE QUIZ


2. THE RULES
3. CREDITS
4. EXIT

Make your choice...!!!

27
1
YOU HAVE CHOSEN 1. PLAY THE QUIZ

Now you have a choice here Sashank


You may either choose to play a SINGLE SUBJECT QUIZ or opt for a COMPLETE 3-SUBJECT
QUIZ
Type 1 for SINGLE SUBJECT QUIZ
Type 2 for COMPLETE 3-SUBJECT QUIZ

The choice is yours...!!!

1
YOU HAVE CHOSEN 1. SINGLE SUBJECT QUIZ

Now select your subject - PHYSICS , CHEMISTRY , BIOLOGY


Type 'P' for PHYSICS
Type 'C' for CHEMISTRY
Type 'B' for BIOLOGY

P
=============================================================================
======
PHYSICS QUESTIONS

Q1 Name the energy transformation that occurs in a nuclear reactor.

A. nuclear mass to heat energy B. nuclear mass to light energy


C. nuclear energy to sound energy D. electrical energy to heat energy
A
Your Answer : A
That's the right answer ...!!! You get 2 points.

Q2 If an object is placed at focus F1, in front of a convex lens


and the image formed is real, inverted and highly enlarged, then
the position of the image is at ...

A. at focus F2 B. at 2F2
C. at infinity D. between F2 and 2F2

28
C
Your Answer : C
That's the right answer ...!!! You get 2 points.

Q3 What parameter does not change when a ray of light undergoes refraction?

A. Wavelength B. Speed
C. Direction D. Frequency

V
Your Answer : V
Oop's! You've got this one wrong.
The correct answer is D. Frequency

You get 0 points.

Q4 Due to repeated reflections at the reflecting surface (as in tombs like the
Taj Mahal , Sikandra), the sound gets prolonged...
The effect is known as __________

A. Echo B. Reverberation
C. Resonance D. Free Vibrations
sa
Your Answer : s
Oop's! You've got this one wrong.
The correct answer is B. Reverberation

You get 0 points.

Q5 A fuse wire is made up of an alloy of lead and tin because it has ...

A. high resistivity and low melting point B. low resistivity and high melting point
C. high resistivity and high melting point D. low resistivity and low melting point

A
Your Answer : A
That's the right answer ...!!! You get 2 points.

29
=============================================================================
==============================

THE GRADE SHEET


NAME - Sashank Kali

SINGLE SUBJECT QUIZ CHOSEN


SUBJECT CHOSEN - PHYSICS

NUMBER OF QUESTIONS ATTEMPTED = 5


NUMBER OF QUESTIONS ANSWERED CORRECTLY = 3

SCORE = 6
YOUR GRADE - C

Satisfactory! You can do better with more effort !!

=============================================================================
==============================
Type 1 for Exit
Type 2 to Continue
2
HERE ARE THE OPTIONS:

1. PLAY THE QUIZ


2. THE RULES
3. CREDITS
4. EXIT

Make your choice...!!!


2
YOU HAVE CHOSEN 2. THE RULES

THE RULES

1. The science quiz for class X ICSE students offer choice to the user to choose between three
science
subjects namely Physics, Chemistry and Biology.

30
2. The user can opt either to play a SINGLE SUBJECT QUIZ (...and choose to play based on choice
of subject)
or a COMPLETE 3-SUBJECT QUIZ (...follow the general sequence of Physics, Chemistry and
Biology).
3. For every question, the user is asked to make his/her choice of the correct answer (choose from 4
displayed options).
4. For every subject, the user gets to answer five questions and for every correct choice, he/she is
awarded 2 marks.
5. At the end, a 'Grade Sheet' is displayed with the user's score and other information.

HERE ARE THE OPTIONS:

1. PLAY THE QUIZ


2. THE RULES
3. CREDITS
4. EXIT

Make your choice...!!!

3
YOU HAVE CHOSEN 3. THE CREDITS

THE CREDITS

******************************************************ABOUT*****************************************************
*

The science quiz project was developed as part of the ICSE Computer applications course for the
year 2014-15.
It was developed and programmed in Java (version 3.1.1) by K.Sashank and Harshit Motiwala.
The program has following components: Name identification, subject choice, rules and credits,
marking and
tracking questions answered correctly, grade card making and display etc.

**************************************************ACKNOWLEDGEMENTS************************************
************

It is a great pleasure to thank those who helped us completing this project work. Firstly, we owe
our deepest gratitude to our teacher, Ms. Nandita Pattanayak, Loyola School, Bhubaneswar. We are
grateful

31
for her valuable guidance, training and encouragement to complete this project. On a personal note,
we
would like to thank our parents, who encouraged us in all possible ways without which we
would not have made it across the finishing line.

Last but not least, we thank the almighty who gave us the strength and perseverance to complete
this work.

******************************************************************************************************************

=============================================================================
=====================================
HERE ARE THE OPTIONS:

1. PLAY THE QUIZ


2. THE RULES
3. CREDITS
4. EXIT

Make your choice...!!!


4
***THANK YOU...!!!***

Program developed by K.Sashank and H.Motiwala

~~JAVA~~

32

You might also like