qu. java

 import java.lang.*;

import java.io.*;

class Questions{

public String [][]qpa; public String[][]qca; 

Questions()throws IOException

{

qpa=new String[10][5];

/*questionsandobjectives*/

DataInputStream in=new DataInputStream(System.in);

qpa[0][0]="who is the father of the computer?"; qpa[0][1]="1.charles babbage";

qpa[0][2]="2.thomas edition"; qpa[0][3]="3. albert einsten";qpa[0][4]="4.isaac newton";


qpa[1][0]="what is the full form of email?"; qpa[1][1]="1.electric mail";

qpa[1][2]="2.exchange mail"; qpa[1][3]="3.electronic mail";

qpa[1][4]="4.engagement mail";


qpa[2][0]="in the virtual world, www stands for?"; qpa[2][1]="1.world without windows";

qpa[2][2]="2.world wide web";

qpa[2][3]="3.world wide web applications";

qpa[2][4]="4.world wide warehouse ";


qpa[3][0]="who invented compact disc?"; qpa[3][1]="1.james t. russell";

qpa[3][2]="2.fujio masuoko";

qpa[3][3]="3.thomas edison";

qpa[3][4]="4.martin cooper";


qca=new String[10][2];

/*questionsandcorrectanswers*/

qca[0][0]="who is the father of the computer?";

 qca[0][1]="1.charles babbage";


qca[1][0]="what is the full form of email?";

qca[1][1]="3.electronic mail";


qca[2][0]="in the virtual world, www stands for?"; 

qca[2][1]="2.world wide web";


qca[3][0]="who invented compact disc?"; 

qca[3][1]="1.james t. russell";

}

}

public class qu{

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

DataInputStream in=new DataInputStream(System.in);

int x,correct=0,wrong=0,i,j; 

String ans[]=new String[10];

Questions q=new Questions(); System.out.println("JAVA QUIZ"); System.out.println(" ");

/*forlooptodisplayquestionandreadtheanswerfromtheuser*/

for(i=0;i<4;i++){

for(j=0;j<5;j++){

System.out.println(q.qpa[i][j]);

}

System.out.println("youranswer:");

 

x=Integer.parseInt(in.readLine()); ans[i]=q.qpa[i][x];

}


/*calculatecorrectanswers*/

for(i=0;i<4;i++){

if(q.qca[i][1].equals(ans[i]))correct++;

 else

wrong++;

}

 

/*printingthecorrectanswersanduserselectedanswers*/ 

System.out.println("CORRECT ANSWERS");

for(i=0;i<4;i++){

System.out.println(); System.out.println(q.qpa[i][0]); System.out.println("correctanswer:"+q.qca[i][1]); System.out.println("youranswer:"+ans[i]);

}

System.out.println("Correct="+correct+"\twrong="+wrong);

}

}

Output

JAVA QUIZ

who is the father of the computer?

1.charles babbage

2.thomas edition

3. albert einsten

4.isaac newton

youranswer:

1

what is the full form of email?

1.electric mail

2.exchange mail

3.electronic mail

4.engagement mail

youranswer:

3

in the virtual world, www stands for?

1.world without windows

2.world wide web

3.world wide web applications

4.world wide warehouse 

youranswer:

2

who invented compact disc?

1.james t. russell

2.fujio masuoko

3.thomas edison

4.martin cooper

youranswer:

1

CORRECT ANSWERS


who is the father of the computer?

correctanswer:1.charles babbage

youranswer:1.charles babbage


what is the full form of email?

correctanswer:3.electronic mail

youranswer:3.electronic mail


in the virtual world, www stands for?

correctanswer:2.world wide web

youranswer:2.world wide web


who invented compact disc?

correctanswer:1.james t. russell

youranswer:1.james t. russell

Correct=4 wrong=0


=== Code Execution Successful ===

Comments

Popular posts from this blog

My Profile

Registration Form

Login form