Advertisement
cesarnascimento

joption, inputdialog, array, função

Aug 18th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package aluno;
  2.  
  3. import javax.swing.JOptionPane;
  4.  
  5. public class AlunoEntrada {
  6.  
  7.     public static void main(String[] args) {
  8.         Aluno aluno[] = new Aluno[3];
  9.         int i;
  10.        
  11.         for(i = 0; i< aluno.length; i++) {
  12.             aluno[i] = new Aluno ();
  13.             aluno[i].nome = JOptionPane.showInputDialog("Nome: ");
  14.             aluno[i].idade = Integer.parseInt(JOptionPane.showInputDialog("Idade: "));
  15.             aluno[i].nota = Double.parseDouble(JOptionPane.showInputDialog("Nota: "));
  16.         }
  17.        
  18.         for(i = 0; i< aluno.length; i++) {
  19.             System.out.println("Nome: "+aluno[i].nome+"- Idade: "+aluno[i].idade+"- Nota: "+aluno[i].nota+ "\n");
  20.         }
  21.        
  22.     }
  23.  
  24. }
  25.  
  26.  
  27. // classe
  28.  
  29.  
  30. package aluno;
  31.  
  32. class Aluno {
  33.     public String nome;
  34.     public int idade;
  35.     public double nota;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement