import javax.swing.JOptionPane;
public class History {
public static void main(String[] args)
{
//First Question: What is the capital of Mexico?
String[] question1 = {"Mexico City", "Paris" //The choseable answers are made using String
,"Washington D.C", "Tokyo"};
String MexicoCapital = (String)JOptionPane.showInputDialog(null, "What is the capital of Mexico?:"
, "Question 1 of 10", JOptionPane.QUESTION_MESSAGE // question number is diplayed on top of text box
, null, question1, question1[0]); //Choices are called and displayed using joptionpane
if (MexicoCapital == null)
{
JOptionPane.showMessageDialog(null, "You didn't pick a city!");
}
else
{
String funfact = "";
switch (MexicoCapital)
{
case "Mexico City":
funfact = "Correct";
break;
case "Paris":
funfact = "Incorrect! Paris is the capital of France";
break;
case "Washington D.C":
funfact = "Incorrect! Washington D.C is the capital of the United States";
break;
case "Tokyo":
funfact = "Incorrect! Tokyo is the capital of Japan";
break;
default:
funfact = "Something went wrong with picking an answer ";
break;
}
JOptionPane.showMessageDialog(null, funfact);
}
//Second Question: When was modern Mexico established?
String[] question2 = {"1954", "1897", "1929", "1789"};
String secondQuestion = (String)JOptionPane.showInputDialog(null, " When was modern Mexico established?:"
, "Question 2 of 10", JOptionPane.QUESTION_MESSAGE
, null, question2, question2[0]);
String funfact = "";
switch (secondQuestion)
{
case "1954":
funfact = "Incorrect, Too Late";
break;
case "1897":
funfact = "Incorrect, Mexico was still a dictatorship then.";
break;
case "1929":
funfact = "Correct, In 1929 the Institutional Revolutionary Party took contol of Mexico";
break;
case "1789":
funfact = "Incorrect, Spain controlled Mexico until 1810";
break;
default:
funfact = "Something went wrong with picking an answer ";
break;
}
JOptionPane.showMessageDialog(null, funfact);
//Third Question:"When did Spain first occupy Mexico?
String[] question3 = {"1923", "1700", "1492", "1834"};
String thirdQuestion = (String)JOptionPane.showInputDialog(null, "When did Spain first occupy Mexico?:"
, "Question 3 of 10", JOptionPane.QUESTION_MESSAGE
, null, question3, question3[0]);
String funfacts = "";
switch (thirdQuestion)
{
case "1923":
funfacts = "Incorrect, Too Late";
break;
case "1700":
funfacts= "Incorrect, Too Late";
break;
case "1492":
funfacts = "Correct,Spain first took control of Mexico in 1492";
break;
case "1289":
funfacts = "Incorrect,The Aztecs had control until 1492";
break;
default:
funfacts = "Something went wrong with picking an answer";
break;
}
JOptionPane.showMessageDialog(null, funfacts);
//Fourth Question: Which of these foods was NOT introduced by Mexicans?
String[] question11 = {"Carrots", "Corn", "Chocolate", "Chili Peppers"};
String fourthQuestion = (String)JOptionPane.showInputDialog(null, "Which of these foods was NOT introduced by Mexicans?:"
, "Question 4 of 10", JOptionPane.QUESTION_MESSAGE
, null, question11, question11[0]);
String funfact2 = "";
switch (fourthQuestion)
{
case "Carrots":
funfact2 = "Correct, Carrots came from Afghanistan";
break;
case "Corn":
funfact2 = "Incorrect,Corn DID originate in Mexico";
break;
case "Chocolate":
funfact2 = "Incorrect,Chocolate DID originate in Mexico";
break;
case "Chili Peppers":
funfact2 = "Incorrect,Chili Peppers DID originate in Mexico";
break;
default:
funfact2 = "Something went wrong with picking an answer ";
break;
}
JOptionPane.showMessageDialog(null, funfact2);
//Fifth Question: What battle ended the Texas Revolution?
String[] question5 = {"Battle of Palo Alto", "Alamo", "Battle of Churubusco", "Battle of Puebla"};
String fifthQuestion = (String)JOptionPane.showInputDialog(null, "What battle ended the Texas Revolution?"
, "Question 5 of 10", JOptionPane.QUESTION_MESSAGE
, null, question5, question5[0]);
String funfacts3 = "";
switch (fifthQuestion)
{
case "Battle of Palo Alto":
funfacts3 = "Incorrect,The Battle of Palo Alto was during the Mexican-American War";
break;
case "Alamo":
funfacts3 = "Correct,The battle for the Alamo was the battle that ended the Texas Revolution";
break;
case "Battle of Churubusco":
funfacts3 = "Incorrect,The Battle of Churubusco was during the Mexican-American War";
break;
case "Battle of Puebla":
funfacts3 = "Incorrect,The Battle of Puebla was a revolt against the French";
break;
default:
funfacts3 = "Something went wrong with picking an answer ";
break;
}
JOptionPane.showMessageDialog(null, funfacts3);
//Sixth Question: How many wars has Mexico been in?
String[] question6 = {"50", "15", "32", "79"};
String sixthQuestion = (String)JOptionPane.showInputDialog(null, "How many wars has Mexico been in?"
, "Question 6 of 10", JOptionPane.QUESTION_MESSAGE
, null, question6, question6[0]);
String funfacts4 = "";
switch (sixthQuestion)
{
case "50":
funfacts4 = "Incorrect,Mexico has only been in 32 official wars";
break;
case "15":
funfacts4 = "Incorrect, Mexico has been in 32 official wars ";
break;
case "32":
funfacts4 = "Correct, Mexico has only been in a total of 32 official wars since the 1600's ";
break;
case "70":
funfacts4 = "Incorrect, Mexico has only been in 32 official wars";
break;
default:
funfacts4 = "Something went wrong with picking an answer ";
break;
}
JOptionPane.showMessageDialog(null, funfacts4);
//Seventh Question:Who is the current President of Mexico?
String[] question7 = {"Fredrik Reinfeldt", "François Hollande", "Nicolás Maduro", "Enrique Peña Nieto"};
String seventhQuestion = (String)JOptionPane.showInputDialog(null, "Who is the current President of Mexico?"
, "Question 7 of 10", JOptionPane.QUESTION_MESSAGE
, null, question7, question7[0]);
String funfacts5 = "";
switch (seventhQuestion)
{
case "Fredrik Reinfeldt":
funfacts5 = "Incorrect,Fredrik Reinfeldt is the Prime Minister of Sweden ";
break;
case "François Hollande":
funfacts5 = "Incorrect,François Hollande is the President of France";
break;
case "Nicolás Maduro":
funfacts5 = "Incorrect,Nicolás Maduro is the President of Venezuela";
break;
case "Enrique Peña Nieto":
funfacts5 = "Correct,Enrique Peña Nieto is the President of Mexico as of December 1,2012";
break;
default:
funfacts5 = "Something went wrong with picking an answer ";
break;
}
JOptionPane.showMessageDialog(null, funfacts5);
//Eighth Question: Which of these countries does Mexico NOT border?
String[] question8 = {"Belize", "United States of America", "Guatemala", "Panama"};
String eighthQuestion = (String)JOptionPane.showInputDialog(null, "Which of these countries does Mexico NOT border?"
, "Question 8 of 10", JOptionPane.QUESTION_MESSAGE
, null, question8, question8[0]);
String funfacts6 = "";
switch (eighthQuestion)
{
case "Belize":
funfacts6 = "Incorrect,Belize borders Mexico to the southeast";
break;
case "United States of America":
funfacts6 = "Incorrect,The United States of America borders Mexico to the north";
break;
case "Guatemala":
funfacts6 = "Incorrect,Guatemala borders Mexico to the southeast";
break;
case "Panama":
funfacts6 = "Correct,Panama does not border Mexico,they are seperated by other countries";
break;
default:
funfacts6 = "Something went wrong with picking an answer ";
break;
}
JOptionPane.showMessageDialog(null, funfacts6);
//Ninth Question:What continent is Mexico located in?
String[] question9 = {"South America", "Europe", "North America", "Africa"};
String ninthQuestion = (String)JOptionPane.showInputDialog(null, "What continent is Mexico located in?"
, "Question 9 of 10", JOptionPane.QUESTION_MESSAGE
, null, question9, question9[0]);
String funfacts7 = "";
switch (ninthQuestion)
{
case "South America":
funfacts7 = "Incorrect,Mexico is located in North America";
break;
case "Europe":
funfacts7 = "Incorrect,Mexico is located in North America";
break;
case "North America":
funfacts7 = "Correct,Mexico is located south of the United States of America, which is in North America";
break;
case "Africa":
funfacts7 = "Incorrect,Mexico is located in North America";
break;
default:
funfacts7 = "Something went wrong with picking an answer ";
break;
}
JOptionPane.showMessageDialog(null, funfacts7);
//Tenth Question:What is Mexico’s official name?
String[] question10 = {"United Mexican States", "Mexican Republic", "Democratic Nation of Mexico", "Kingdom of Mexico"};
String tenthQuestion = (String)JOptionPane.showInputDialog(null, "What is Mexico’s official name?"
, "Final Question", JOptionPane.QUESTION_MESSAGE
, null, question10, question10[0]);
String funfacts8 = "";
switch (tenthQuestion)
{
case "United Mexican States":
funfacts8 = "Correct,Mexico's official name is the United Mexican States.";
break;
case "Mexican Republic":
funfacts8 = "Incorrect,Mexico is not a republic it is a democracy";
break;
case "Democratic Nation of Mexico":
funfacts8 = "Incorrect,Mexico's official name is the United Mexican States." ;
break;
case "Kingdom of Mexico":
funfacts8 = "Incorrect,Mexico is not a kingdom, it is a democracy";
break;
default:
funfacts8 = "Something went wrong with picking an answer ";
break;
}
JOptionPane.showMessageDialog(null, funfacts8);
//Closing Statements
JOptionPane.showMessageDialog(null,"Thank you for taking the History quiz.We hope you will also play the trivia game.");
}
}