• Lenguaje

    Java usando Scanner

  • Descripción

    Dados como datos dos variables de tipo entero, obtenga el resultado de la siguiente función:

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

public class Funcion100X100X100X {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int NUM, x, y;
        System.out.print("Ingresa el valor de NUM: ");
        NUM = in.nextInt();
        in.nextLine();
        System.out.print("Ingresa el valor de x: ");
        x = in.nextInt();
        in.nextLine();
        y=0;
        if(NUM==1)
            y=100.0*x;
        if(NUM==2)
            y=Math.pow(100,x);
        if(NUM==3)
            y=100.0/x;
        System.out.println("Valor de y: " + y);
    }

}