Advertisement
Guest User

Untitled

a guest
Jan 29th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. public class Aluno {
  2.    
  3.     String nome;
  4.     int idade;
  5.    
  6.     public Aluno(String nome,int idade) {
  7.         this.nome = nome;
  8.         this.idade = idade;
  9.        
  10.     }
  11.  
  12.  
  13. }
  14.  
  15. import java.util.Scanner;
  16.  
  17. public class Principal {
  18.   public static void main(String[] args) {
  19.      
  20.       Scanner entrada = new Scanner(System.in);
  21.       int idade = 0;
  22.       String nome = null;
  23.     Aluno aluno = new Aluno(nome, idade);
  24.     System.out.println("Qual tu nome");
  25.     aluno.nome = entrada.nextLine();
  26.    
  27.     System.out.println("Qual tu idade");
  28.     aluno.idade = entrada.nextInt();
  29.    
  30.     System.out.println("Nome: " + aluno.nome + "\nIdade: " + aluno.idade);   
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement