-
Lenguaje
Java usando Scanner
-
Descripción
Calcule el valor de R de acuerdo a la siguiente relación:
R = (A * B) / (C * D) Si X * Y > 0
R = (A + B) / (C + D) Si X * Y = 0
R = (A + B) – C + D Si X * Y < 0
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
27
28
29
30
31
32
33
34
35
36
37
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
27
28
29
30
31
32
33
34
35
36
37
import java.util.Scanner;
public class ValorDeR {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double A, B, C, D, R;
double X, Y;
System.out.print("Ingresa el valor de A: ");
A = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de B: ");
B = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de C: ");
C = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de D: ");
D = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de X: ");
X = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de Y: ");
Y = in.nextDouble();
in.nextLine();
R=0;
if(X*Y>0)
R=(A*B)/(C*D);
if(X*Y==0)
R=(A+B)/(C+D);
if(X*Y<0)
R=(A+B)-C+D;
System.out.println("Valor de R: " + R);
}
}
public class ValorDeR {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double A, B, C, D, R;
double X, Y;
System.out.print("Ingresa el valor de A: ");
A = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de B: ");
B = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de C: ");
C = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de D: ");
D = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de X: ");
X = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de Y: ");
Y = in.nextDouble();
in.nextLine();
R=0;
if(X*Y>0)
R=(A*B)/(C*D);
if(X*Y==0)
R=(A+B)/(C+D);
if(X*Y<0)
R=(A+B)-C+D;
System.out.println("Valor de R: " + R);
}
}