Question:
debug the following code....its correct but static variables causing so much problem! god! please help!stuck!?
Aparna
2010-06-08 12:05:28 UTC
// K B C ( kAUN bANEGA cROREpATI )!!!!

import java.util.*;
public class KBC
{ String questions[];
String options[][];
int answers[];
long money[];

public KBC()
{ questions = new String[]
{ " Where is Fort William located ?",
" Name this Indian Tennis player who has turned Hollywood filmmaker?",
" Sishu is the literary work of which Indian author?",
" Which of these Cities located in the state of Gujarat is famous for zari production?",
" Which State in India is the largest producer of Soyabean?",
" The western ghats in Maharashtra is known as...?",
" On which riverbank is Goa located?",
" Which state is known as India's Spice Garden...?",
" Thumba in Kerala is famous because...?",
" Which of these places is not located in Mumbai?",
" Name the annual fair of Rajasthan that is famous for its camel trading event...?",
" Which Indian State has most airports?",
" Name the oldest mountain range of India...?",
" Rouff is a folk dance. It has its origin in ...?",
" Located in India it is Asia's largest residential university. Name it...?"
};

options = new String[][]
{
{ "1.Chennai","2.Goa","3.Kolkata","4.Mysore"},
{"1.Leander Paes","2.Mahesh Bhupathi","3. Vijay Amritraj","4.Ashok Amritraj"},
{"1.Vikram Seth","2.Jawaharlal Nehru","3.Rabindranath Tagore","4.Arundhati Roy"},
{"1.Surat","2.Rajkot","3.Surendranagar","4.Ahmedabad"},
{"1.Rajasthan","2.Gujarat","3.Uttar Pradesh","4.Madhya Pradesh"},
{"1.Nilgiris","2.Sahyadris ","3.Cardamon Hills","4.Annamalai"},
{"1.Ganga","2.Mandovi","3.Gomati","4.Sabarmati"},
{"1.Kerala","2.Karnataka","3.Bihar","4.Uttaranchal"},
{"1.It has several industries","2.It is a rocket launching station","3.It is a harbour","4.It has an international airport"},
{"1.The Gateway of India","2.The Kamala Nehru Park","3.The Juhu Beach","4.The Charminar"},
{"1.Pushkar Mela","2.Kumbha Mela","3.Sonepur Mela","4.Suraj Kund Mela"},
{"1.Maharashtra","2.Madhya Pradesh","3.Kerala","4.Gujarat"},
{"1.Himalayas","2.Nilgiris","3.Aravallis","4.Vindhyas"},
{"1.Himachal Pradesh","2.Assam","3.Mizoram","4.Kashmir"},
{"1.Banaras Hindu University","2.The Utkal University","3.Jawaharlal Nehru University","4.Anna University"}

};
answers = new int[]
{3,4,3,1,4,2,2,1,2,4,1,4,3,4,1};

money = new long[]
{ 1000,2000,3000,5000,10000,20000,40000,80000,160000,320000,640000,1250000,2500000,5000000,10000000};

}
public int getRandomQues()
{ int i = (int)((Math.random()*15)+1);
return i ;
}


public int[] getHistory(int i)
{ int k;
int arr[]=new int[15];
arr[k]=i;
k++;
return arr;
}

public static void main( String args[])
{ Scanner sc = new Scanner(System.in);
KBC obj = new KBC();
static int ctr;
int choice=0;
for(int k=0;k!=obj.questions.length;k++)
{ int i= obj.getRandomQues();
boolean res;
if(ctr>0)
{
int q[]=obj.getHistory(i);
for( int t=0;t!=q.length;t++)
{ if(i!=q[t])
res=true;
else
res=false;
}
if(res==true)
{


{ System.out.println( k+1+" : " + obj.questions[i]);
System.out.println(obj.options[i][0]);
System.out.println(obj.options[i][1]);
System.out.println(obj.options[i][2]);
System.out.println(obj.options[i][3]);
}
System.out.println(" Enter your choice(1/2/3/4)");
choice = Integer.parseInt(sc.nextLine());
if(choice==obj.answers[i])
System.out.println("You have won : " + obj.money[k]);
else
{ System.out.println(" G.A.M.E O.V.E.R S.U.C.K.ER ");
break;
}
}
else
continue;
}
ctr++;
}
}
}
Three answers:
53MalePrison
2010-06-08 12:11:30 UTC
Causing what sort of problems?
Jessica
2016-04-15 02:21:40 UTC
"If the total amount of mass-energy is limited, and the amount of usable energy is decreasing, then the universe cannot have existed forever, otherwise it would already have exhausted all usable energy the heat death of the universe." Mass-energy may be limited, and the amount of USABLE energy may be decreasing, but that does not necessarily signify the end of the universe caused by the lack of energy to do work. The amount of energy remains the same. Total equilibrium of energy or "heat" in the universe does not mean the energy ceases to exist. It means that all things that require work as a function of energy to exist can no longer exist. However, the total amount of mass-energy will remain the same. You can state will absolute assurance that the universe has a beginning, only if you have absolute proof that the universe has an end. "The universe requires a cause because it had a beginning" Can we be absolutely sure that the universe had a beginning? If it has no end it has no beginning. Therefore it could have always existed. If "God" does not need a cause because He always existed, then why would a universe need a cause if it has always existed? How can we not be sure that the universe will not exist eternally in a state of equilibrium? What if the universe was not created for the purpose of human beings? "Also, the universe cannot be self-caused nothing can create itself, because that would mean that it existed before it came into existence, which is a logical absurdity." I agree with you there. Of course, a cause cannot be caused by itself. This is valid logic. On the other hand I do have one ponderous thought about time and God. If he caused the universes' beginning, he is a cause. Therefore, would he not be able to produce both cause and effects at His will? Time, like you've stated, "Einstein's general relativity, which has much experimental support, shows that time is linked to matter and space.", is a rate of change. However, I believe that time is a product of any type of change. Or cause and effect. Therefore, would God not be living in his own time? Whether it be constantly varying in speed or not. As he is acting or changing time passes as an effect. Time will not exist only when absolutely nothing exists, including God. However, I am not stating with for a fact that there is not a beginning to the universe. I am simply using logic to seek the truth. However, like all humans I make mistakes because I do not know everything. I am simply using my understanding of what I "know" to produce logical explanations. Maybe there is information out there that proves the universe did begin at a certain instant and that all things in it followed. This is a very interesting question. I like that you used logic to support your argument. That is how it should be done. And don't get me wrong. I'm not trying to disprove you here. I want the same thing you want. The truth. I have questions and I am simply trying to find the answer.
anonymous
2010-06-08 12:12:24 UTC
you can't declare a variable static inside a method. a static variable is a class variable. From what I know about Java, you need to declare it final static variable for it to work. It would be the equivalent to constant in c++ / c#


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...