Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package progetpersona;
- import java.io.*;
- public class persona
- {
- private String nome;
- private String cognome;
- private int anno;
- public void acq()
- {
- InputStreamReader input = new InputStreamReader(System.in); // impostazione dello standard input
- BufferedReader tastiera = new BufferedReader(input);
- System.out.println("inserisci il nome della persona:");
- try
- {
- nome = tastiera.readLine();
- }
- catch(Exception e)
- {
- }
- System.out.println("inserisci il cognome della persona:");
- try
- {
- cognome = tastiera.readLine();
- }
- catch(Exception e)
- {
- }
- System.out.println("Inserisci il suo anno di nascita:");
- try
- {
- String annoLetto = tastiera.readLine();
- anno= Integer.valueOf(annoLetto).intValue();
- }
- catch(Exception e)
- {
- System.out.println("\nErrore! Inserire un valore valido");
- }
- }
- public int calviseta()
- {
- int eta;
- eta = 2016 - anno;
- System.out.println( nome + " " + cognome + " ha " + eta + " anni");
- return eta;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement