• Lenguaje

    Java usando Scanner

  • Descripción

    El director de un colegio requiere determinar el tiempo que tienen laborando los docentes a su cargo, pero necesita saber el año en que ingresaron a laborar.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import java.util.Scanner;

public class TiempoLaborando {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int ano_actual, ano_de_ingreso, tiempo;
        System.out.print("Ingresa el valor de ano actual: ");
        ano_actual = in.nextInt();
        in.nextLine();
        System.out.print("Ingresa el valor de ano de ingreso: ");
        ano_de_ingreso = in.nextInt();
        in.nextLine();
        tiempo=ano_actual-ano_de_ingreso;
        System.out.println("Valor de tiempo: " + tiempo);
    }

}