Quiz em Java para celular

3 respostas
W

Boa noite a todos,

Estou precisando desenvolver um quiz com um banco de dados de 30 perguntas, mas essas perguntas tem que aparecer randomicamente de 5 em 5 e depois me mostrar o resultado, comecei a fazer e ja to com problema, me digam o que esta errado com o código abaixo pq ele não esta compilando.

package quiz_estacio;

import java.util.Scanner;
public class pergunta {
    public static void main(string []args);
    {
int c = 0;
        Scanner = scan = new Scanner ( System.in );
        
        System.out.println("Número de estados da Região Sudeste do Brasil");
        System.out.println("4");
        System.out.println("3");
        System.out.println("5");
        System.out.println("2");
        
        String in;
        in = Scanner.nextLine();
        
        if (in.equals("4")){
            System.out.println("Correto");
            c++;
        } else {
            System.out.printls("Errado");
    }
}
}

Obrigado pela ajuda.

OBS: Sou novato em Java

3 Respostas

A
wellrodrigues:
Boa noite a todos,

Estou precisando desenvolver um quiz com um banco de dados de 30 perguntas, mas essas perguntas tem que aparecer randomicamente de 5 em 5 e depois me mostrar o resultado, comecei a fazer e ja to com problema, me digam o que esta errado com o código abaixo pq ele não esta compilando.

package quiz_estacio;

import java.util.Scanner;
public class pergunta {
    public static void main(string []args);
    {
int c = 0;
        Scanner = scan = new Scanner ( System.in );
        
        System.out.println("Número de estados da Região Sudeste do Brasil");
        System.out.println("4");
        System.out.println("3");
        System.out.println("5");
        System.out.println("2");
        
        String in;
        in = Scanner.nextLine();
        
        if (in.equals("4")){
            System.out.println("Correto");
            c++;
        } else {
            System.out.printls("Errado");
    }
}
}

Obrigado pela ajuda.

OBS: Sou novato em Java

Olá colega.

Você poderia ter postado a mensagem de erro que a IDE te forneceu.

Porém, visualizando rapidamente, tente tirar esse ponto e virgula

public static void main(string []args);

Espero ter ajudado.

Artur Martini

W

Entendi mas agora deu outro erro e aparece isto

<blockquote>ant -f C:\Users\Wellington Rodrigues\Documents\NetBeansProjects\quiz -Ddist.jad.url=http://localhost:8082/servlet/org.netbeans.modules.mobility.project.jam.JAMServlet/C%3A/Users/Wellington+Rodrigues/Documents/NetBeansProjects/quiz/dist//quiz.jad run

pre-init:

pre-load-properties:

exists.config.active:

exists.netbeans.user:

exists.user.properties.file:

load-properties:

exists.platform.active:

exists.platform.configuration:

exists.platform.profile:

basic-init:

cldc-pre-init:

cldc-init:

cdc-hi-pre-init:

cdc-hi-init:

post-init:

init:

conditional-clean-init:

conditional-clean:

deps-jar:

pre-preprocess:

do-preprocess:

Pre-processing 0 file(s) into C:\Users\Wellington Rodrigues\Documents\NetBeansProjects\quiz\build\preprocessed directory.

post-preprocess:

preprocess:

pre-compile:

extract-libs:

Expanding: C:\Program Files\NetBeans 7.3.1\mobility\modules\ext\netbeans_midp_components_basic.jar into C:\Users\Wellington Rodrigues\Documents\NetBeansProjects\quiz\build\compiled

do-compile:

Compiling 3 source files to C:\Users\Wellington Rodrigues\Documents\NetBeansProjects\quiz\build\compiled

C:\Users\Wellington Rodrigues\Documents\NetBeansProjects\quiz\src\quiz\NewClass.java:1: error: cannot find symbol

import java.util.Scanner;

symbol:   class Scanner

location: package java.util

C:\Users\Wellington Rodrigues\Documents\NetBeansProjects\quiz\src\quiz\NewClass.java:6: error: cannot find symbol

Scanner scan = new scanner(System.in);

symbol:   class Scanner

location: class NewClass

C:\Users\Wellington Rodrigues\Documents\NetBeansProjects\quiz\src\quiz\NewClass.java:6: error: cannot find symbol

Scanner scan = new scanner(System.in);

symbol:   class scanner

location: class NewClass

C:\Users\Wellington Rodrigues\Documents\NetBeansProjects\quiz\src\quiz\NewClass.java:6: error: cannot find symbol

Scanner scan = new scanner(System.in);

symbol:   variable in

location: class System

4 errors

C:\Users\Wellington Rodrigues\Documents\NetBeansProjects\quiz\nbproject\build-impl.xml:188: Compile failed; see the compiler error output for details.

FALHA NA CONSTRUÇÃO (tempo total: 0 segundos)</blockquote>
michel79

Reveja a linha 8 do seu código

Criado 28 de setembro de 2013
Ultima resposta 30 de set. de 2013
Respostas 3
Participantes 3