• Lenguaje

    Java usando Scanner

  • Descripción

    Un postulante a un empleo, realiza un test de capacitación, se obtuvo la siguiente información: cantidad total de preguntas que se le realizaron y la cantidad de preguntas que contestó correctamente. Se pide confeccionar un programa que ingrese los dos datos por teclado e informe el nivel del mismo según el porcentaje de respuestas correctas que ha obtenido, y sabiendo que:
    - Nivel máximo: Porcentaje >= 90%.
    - Nivel medio: Porcentaje >= 75% y < 90%.
    - Nivel regular: Porcentaje >= 50% y < 75%.
    - Fuera de nivel: Porcentaje < 50%.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.util.Scanner;

public class TestDeCapacitacion {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double porcentaje, preguntas_correctas, total_de_preguntas;
        System.out.print("Ingresa el valor de preguntas correctas: ");
        preguntas_correctas = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de total de preguntas: ");
        total_de_preguntas = in.nextDouble();
        in.nextLine();
        porcentaje=100.0*preguntas_correctas/total_de_preguntas;
        if(porcentaje>=90)
            System.out.println("Nivel m\u00E1ximo");
        if(porcentaje>=75&&porcentaje<90)
            System.out.println("Nivel medio");
        if(porcentaje>=50&&porcentaje<75)
            System.out.println("Nivel regular");
        if(porcentaje<50)
            System.out.println("Fuera de nivel");
        System.out.println("Valor de porcentaje: " + porcentaje);
    }

}