HOW TO CREATE KBC GAME IN JAVA
--------------------------------------------------------------------------------------------------------------------------
import java.util.*;class kbc
{
public static void main(String args[])
{ int t=1,tp=0;
char an='0',an1='0',an2='0',an3='0',an4='0';
while(t>=1)
{
String A[]={"Where was the first Constituent Assembly held ?","Which planet looks reddish in the night sky ?","Which bank is the banker of the banks ?","'Gobar gas' contains mainly which gas ?","Which is the biggest lake in india ?"};
char n[]={'B','D','C','A','B'};
int p=0,q=0;
String na="";
Scanner sc=new Scanner(System.in);
System.out.println(" WELCOME ");
System.out.println(" KON BANEGA CROREPATI 2017 ");
System.out.println("if u want to start the game press Y for YES if not then press N for NO");
char a=sc.next().charAt(0);
if(a=='Y')
{
System.out.println("........THE FIRST QUSTION ON YOUR SCREEN........");
System.out.println(A[0]);
System.out.print("A)LUCKNOW B)DELHI");
System.out.println(" C)KANPUR D)BANARAS");
System.out.println("Enter your option");
}
an=sc.next().charAt(0);
if(n[0]==an)
{
System.out.println("<<<<Congrats your answer is correct>>>>");
System.out.println("You have won Rs.1000/-");
p=1000;
System.out.println("press Y for next Question");
char y=sc.next().charAt(0);
System.out.println("........THE Second QUSTION ON YOUR SCREEN........");
System.out.println(A[1]);
System.out.print("A)JUPITER B)SUN");
System.out.println(" C)VENUS D)MARS");
System.out.println("Enter your option");
an1=sc.next().charAt(0);
}
if(n[1]==an1)
{
System.out.println("<<<<Congrats your answer is correct>>>>");
System.out.println("You have won Rs.2000/-");
p=p+1000;
System.out.println("press Y for next Question");
char Y1=sc.next().charAt(0);
System.out.println("........THE Third QUSTION ON YOUR SCREEN........");
System.out.println(A[2]);
System.out.print("A)SBI B)BOB");
System.out.println(" C)RBI D)CBI");
System.out.println("Enter your option");
an2=sc.next().charAt(0);
}
if(n[2]==an2)
{
System.out.println("<<<<Congrats your answer is correct>>>>");
System.out.println("You have won Rs.3000/-");
p=p+1000;
System.out.println("press Y for next Question");
char Y2=sc.next().charAt(0);
System.out.println("........THE forth QUSTION ON YOUR SCREEN........");
System.out.println(A[3]);
System.out.print("A)METHANE B)NITROGEN");
System.out.println(" C)OXYGEN D)HYDROGEN");
System.out.println("Enter your option");
an3=sc.next().charAt(0);
}
if(n[3]==an3)
{
System.out.println("<<<<Congrats your answer is correct>>>>");
System.out.println("You have won Rs.4000/-");
p=p+1000;
System.out.println("press Y for next Question");
char Y2=sc.next().charAt(0);
System.out.println("........THE forth QUSTION ON YOUR SCREEN........");
System.out.println(A[4]);
System.out.print("A)GANGA B)CHILKA LAKE");
System.out.println(" C)NILE D)TAPU");
System.out.println("Enter your option");
an4=sc.next().charAt(0);
}
if(n[4]==an4)
{
System.out.println("<<<<Congrats your answer is correct>>>>");
System.out.println("You have won Rs.5000/-");
p=p+1000;
}
else
{
tp=p;
System.out.println("<<<<oppsss your answer is wrong>>>>");
System.out.println("total amount you win = "+tp);
}
System.out.println("if you want to play again then enter Y and if not then press N");
char w=sc.next().charAt(0);
if(w=='Y')
{
t=1;
}
else
{
t=0;
}
}
}
}
--------------------------------------end--------------------------------------
PRIME NUMBER PROGRAM THROUGH JAVA
Code :
import java.util.*;class prime
{
public static void main(String hee[])
{
Scanner sc=new Scanner(System.in);
System.out.println("enter the prime number");
int a=sc.nextInt();
//int c=0;
if(a%2==0)
{
System.out.println("prime no:"+a);
}
else
{
System.out.println("not prime:"+a);
}
}
}
------------------end-----------
No comments:
Post a Comment