Páginas

terça-feira, 14 de maio de 2019

Provaa

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package prova;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

/**
 *
 * @author aluno
 */
public class Prova {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner leituraArquivo = null;
        Scanner teclado = new Scanner (System.in);
        int qtd =0, pontuacao;
        String candidato;
       
        Candidato[] candidatos = new Candidato[200];
        try {//abrindo arquivo para leitura
            leituraArquivo = new Scanner(new FileReader("valores.txt"));
}catch (FileNotFoundException e) {
// TODO Auto-generated catch block
            e.printStackTrace();
        }
        while (leituraArquivo.hasNext()){
            pontuacao = leituraArquivo.nextInt();
            candidato = leituraArquivo.nextLine();
            candidatos[qtd] = new Candidato(candidato, pontuacao) ;
            qtd++;           
        }
        System.out.println("Informe a quantidade de vagas: ");
        int vagas = teclado.nextInt();
       
        for (int i =0; i< vagas; i++){
            System.out.println(candidatos[i].toString());
        }
        if (candidatos[vagas-1].getPontuacao()==candidatos[vagas].getPontuacao()){
            System.out.println("Há empate!");
           
        }
    }
}

Sem comentários:

Enviar um comentário