Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.90 KB | None | 0 0
  1. import java.util.Scanner;
  2. import javax.swing.*;
  3. import javax.swing.JOptionPane;
  4. public class Mundial {
  5.  
  6.     public static void main(String[] args) {
  7.         int menu;
  8.         Scanner entrada = new Scanner (System.in);
  9.        
  10.           String pregunta1="¿Quien ganó la copa mundial en 2010?";
  11.             String respuesta_1_1="España";
  12.             String respuesta_1_2="Francia";
  13.             String respuesta_1_3="Alemania";
  14.             String respuesta_1_4="Uruguay";
  15.             int opcion_correcta1=1;
  16.              
  17.             String pregunta2="¿Quien obtuvo el balon de oro en el mundial de 2014?";
  18.             String respuesta_2_1="Cristiano Ronaldo";
  19.             String respuesta_2_2="Diego Forlan";
  20.             String respuesta_2_3="Lionel Messi";
  21.             String respuesta_2_4="David Beckham";
  22.             int opcion_correcta2=3;
  23.              
  24.             String pregunta3="¿Cual es la longitud (en metros) de los arcos usados en el mundial 2014?";
  25.             String respuesta_3_1="7,32";
  26.             String respuesta_3_2="10,23";
  27.             String respuesta_3_3="8,49";
  28.             String respuesta_3_4="4,57";
  29.             int opcion_correcta3=1;
  30.            
  31.             String pregunta4="¿En que año nacio Cristiano Ronaldo?";
  32.             String respuesta_4_1="1987";
  33.             String respuesta_4_2="1991";
  34.             String respuesta_4_3="1985";
  35.             String respuesta_4_4="1976";
  36.             int opcion_correcta4=3;
  37.            
  38.             String pregunta5="¿En que estadio Uruguay le gano a brasil logrando ser campeones del mundo?";
  39.             String respuesta_5_1="1946";
  40.             String respuesta_5_2="1956";
  41.             String respuesta_5_3="1950";
  42.             String respuesta_5_4="1948";
  43.             int opcion_correcta5=3;
  44.            
  45.             String pregunta6="¿Actualmente quien lleva el apodo de El pistolero uruguayo?";
  46.             String respuesta_6_1="Diego Forlan";
  47.             String respuesta_6_2="Luis Suarez";
  48.             String respuesta_6_3="Diego Lugano";
  49.             String respuesta_6_4="Edinson Cavani";
  50.             int opcion_correcta6=2;
  51.            
  52.             String pregunta7="¿Quien fue el director tecnico de la seleccion uruguaya en el año 2010?";
  53.             String respuesta_7_1="Washintong Tabarez";
  54.             String respuesta_7_2="Jorge Da Silva";
  55.             String respuesta_7_3="Marcelo Gallardo";
  56.             String respuesta_7_4="Manuel Keosseian";
  57.             int opcion_correcta7=1;
  58.            
  59.             String pregunta8="¿Como se llama el estadio en donde se jugo la final del Mundial 2014?";
  60.             String respuesta_8_1="Arena de São Paulo";
  61.             String respuesta_8_2="Estadio Nacional";
  62.             String respuesta_8_3="Estadio das Dunas";
  63.             String respuesta_8_4="Maracana";
  64.             int opcion_correcta8=4;
  65.            
  66.            
  67.             String pregunta9="¿En donde se jugo la primera Copa Mundial?";
  68.             String respuesta_9_1="Brasil";
  69.             String respuesta_9_2="Argentina";
  70.             String respuesta_9_3="España";
  71.             String respuesta_9_4="Uruguay";
  72.             int opcion_correcta9=4;
  73.            
  74.             String pregunta10="¿Cual es el nombre completo de Messi?";
  75.             String respuesta_10_1="Lionel Sebastian Messi Vazquez";
  76.             String respuesta_10_2="Lionel Santiago Messi Ficolini";
  77.             String respuesta_10_3="Lionel Andrés Messi Cuccittini";
  78.             String respuesta_10_4="Lionel Messi Silvera";
  79.             int opcion_correcta10=3;
  80.            
  81.    
  82.              
  83.             String pregunta_actual="";
  84.             String respuesta_actual1="";
  85.             String respuesta_actual2="";
  86.             String respuesta_actual3="";
  87.             String respuesta_actual4="";
  88.             int opcion_correcta=0;
  89.             String respuesta_verificar="";
  90.              
  91.             int inicio=1;
  92.             int limite=10;
  93.             int ultimo=0;
  94.             int opcion_ok=0;
  95.             int cant_respuestas_correctas=0;
  96.             int cant_respuestas_incorrectas=0;
  97.              
  98.             for(int x=0;x<10;x++)
  99.             {          
  100.                  int aleatorio=0;
  101.                  do
  102.                  {
  103.                      System.out.println("Menú de opciones\n\n1-Jugar \n2-Descripcion \n3-Puntajes \n4-Creditos");
  104.                     menu = entrada.nextInt();
  105.                      aleatorio= inicio + (int) (Math.random() * ((limite + 1) - inicio));                
  106.                  }while(ultimo==aleatorio);
  107.                  ultimo=aleatorio;
  108.                
  109.                  
  110.                  switch(aleatorio)
  111.                  {
  112.                     case 1:
  113.                         pregunta_actual=pregunta1;
  114.                         respuesta_actual1=respuesta_1_1;
  115.                         respuesta_actual2=respuesta_1_2;
  116.                         respuesta_actual3=respuesta_1_3;
  117.                         respuesta_actual4=respuesta_1_4;
  118.                         opcion_ok=opcion_correcta1;
  119.                     break;
  120.                      
  121.                     case 2:
  122.                         pregunta_actual=pregunta2;
  123.                         respuesta_actual1=respuesta_2_1;
  124.                         respuesta_actual2=respuesta_2_2;
  125.                         respuesta_actual3=respuesta_2_3;
  126.                         respuesta_actual4=respuesta_2_4;
  127.                         opcion_ok=opcion_correcta2;
  128.                     break;
  129.                      
  130.                     case 3:
  131.                         pregunta_actual=pregunta3;
  132.                         respuesta_actual1=respuesta_3_1;
  133.                         respuesta_actual2=respuesta_3_2;
  134.                         respuesta_actual3=respuesta_3_3;
  135.                         respuesta_actual4=respuesta_3_4;
  136.                         opcion_ok=opcion_correcta3;
  137.                     break;
  138.                    
  139.                     case 4:
  140.                         pregunta_actual=pregunta4;
  141.                         respuesta_actual1=respuesta_4_1;
  142.                         respuesta_actual2=respuesta_4_2;
  143.                         respuesta_actual3=respuesta_4_3;
  144.                         respuesta_actual4=respuesta_4_4;
  145.                         opcion_ok=opcion_correcta4;
  146.                     break;
  147.                    
  148.                     case 5:
  149.                         pregunta_actual=pregunta5;
  150.                         respuesta_actual1=respuesta_5_1;
  151.                         respuesta_actual2=respuesta_5_2;
  152.                         respuesta_actual3=respuesta_5_3;
  153.                         respuesta_actual4=respuesta_5_4;
  154.                         opcion_ok=opcion_correcta5;
  155.                     break;
  156.                    
  157.                     case 6:
  158.                         pregunta_actual=pregunta6;
  159.                         respuesta_actual1=respuesta_6_1;
  160.                         respuesta_actual2=respuesta_6_2;
  161.                         respuesta_actual3=respuesta_6_3;
  162.                         respuesta_actual4=respuesta_6_4;
  163.                         opcion_ok=opcion_correcta6;
  164.                     break;
  165.                    
  166.                     case 7:
  167.                         pregunta_actual=pregunta7;
  168.                         respuesta_actual1=respuesta_7_1;
  169.                         respuesta_actual2=respuesta_7_2;
  170.                         respuesta_actual3=respuesta_7_3;
  171.                         respuesta_actual4=respuesta_7_4;
  172.                         opcion_ok=opcion_correcta7;
  173.                     break;
  174.                    
  175.                     case 8:
  176.                         pregunta_actual=pregunta8;
  177.                         respuesta_actual1=respuesta_8_1;
  178.                         respuesta_actual2=respuesta_8_2;
  179.                         respuesta_actual3=respuesta_8_3;
  180.                         respuesta_actual4=respuesta_8_4;
  181.                         opcion_ok=opcion_correcta8;
  182.                     break;
  183.                    
  184.                     case 9:
  185.                         pregunta_actual=pregunta9;
  186.                         respuesta_actual1=respuesta_9_1;
  187.                         respuesta_actual2=respuesta_9_2;
  188.                         respuesta_actual3=respuesta_9_3;
  189.                         respuesta_actual4=respuesta_9_4;
  190.                         opcion_ok=opcion_correcta9;
  191.                     break;
  192.                    
  193.                     case 10:
  194.                         pregunta_actual=pregunta10;
  195.                         respuesta_actual1=respuesta_10_1;
  196.                         respuesta_actual2=respuesta_10_2;
  197.                         respuesta_actual3=respuesta_10_3;
  198.                         respuesta_actual4=respuesta_10_4;
  199.                         opcion_ok=opcion_correcta10;
  200.                     break;
  201.                    
  202.                  }
  203.                  
  204.                  respuesta_verificar=JOptionPane.showInputDialog("Pregunta...."+(x+1)+"\n"+pregunta_actual+"\nIngrese su Respuesta:\n1. "+respuesta_actual1+"\n2. "+respuesta_actual2+"\n3."+respuesta_actual3+"\n4."+respuesta_actual4);
  205.                  opcion_correcta=Integer.parseInt(respuesta_verificar);
  206.                  if(opcion_correcta1==opcion_ok)
  207.                  {
  208.                      cant_respuestas_correctas++;
  209.                  }
  210.                  else
  211.                  {
  212.                      cant_respuestas_incorrectas++;
  213.                  }          
  214.             }
  215.              
  216.             JOptionPane.showMessageDialog(null,"¡Usted ha anotado " +  cant_respuestas_correctas +  " puntos!");
  217.             }
  218.            
  219.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement