Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.92 KB | None | 0 0
  1. package exercicio;
  2.  
  3. import static java.sql.Types.NULL;
  4. import java.util.ArrayList;
  5. import java.util.Scanner;
  6. import javax.swing.JOptionPane;
  7.  
  8. public class Exercicio9 {
  9.  
  10.     static ArrayList<EXE9> alunos = new ArrayList<>();
  11.     static Scanner leia = new Scanner(System.in);
  12.  
  13.     public static void main(String[] args) {
  14.      //   EXE9 ftp = new EXE9();
  15.        
  16.         String nomeMaior = "";
  17.         String nomeMenor = "";
  18.         float maior = 0;
  19.         float menor = 10;
  20.         int val = 0;
  21.         int x = 0;
  22.         //menor = ftp.getNota();
  23.         while (val < 3) {
  24.            //System.out.print("Nome............: "+ menor);
  25.             JOptionPane.showMessageDialog(null, "Incluir novo Aluno" );
  26.             String Nome = JOptionPane.showInputDialog("Nome.........: ");
  27.             String nome = (Nome);
  28.             String Nota = JOptionPane.showInputDialog("Nota..........: ");
  29.             float nota = Float.parseFloat(Nota);
  30.             String con = JOptionPane.showInputDialog("Confirma a inclusão do Aluno? :");
  31.             String conf = (con);
  32.             if (conf.equals("S") || conf.equals("s")||conf.equals("") ) {
  33.                 EXE9 Alunos = new EXE9(nome, nota);
  34.                 Exercicio9.alunos.add(Alunos);
  35.                 val++;
  36.             }
  37.         }
  38.             for (int i = 0;i <= (val+1);i++){
  39.                for (EXE9 sor : alunos) {
  40.                     if ((sor.getNota()) > (maior)) {
  41.                         nomeMaior = (sor.getNome());
  42.                         maior = (sor.getNota());
  43.                     } else if ((sor.getNota()) < (menor)){
  44.                         nomeMenor = (sor.getNome());
  45.                         menor = (sor.getNota());
  46.                     }
  47.                 }
  48.              JOptionPane.showMessageDialog(null, i +"Nome......: " + nomeMenor + " Menor Nota......: " + menor + "\nNome......: " + nomeMaior + " Maior Nota.....: " + maior);      
  49. }
  50.  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement