-
Lenguaje
Java usando Scanner
-
Descripción
Ingresar el nombre del cliente y seleccione un tipo de equipo como:
1.- Laptop
2.- Móvil
3.- Tablet
Luego ingrese el precio y cantidad del equipo. Así mismo, se obtendrá un descuento a partir de la compra de 4 equipos a más.
Condicionar:
- Si el equipo es Laptop tendrá un descuento de 15%,
- Si es Móvil su descuento es de 10%
- Si es Tablet su descuento es de 12%.
Hallar el descuento y el monto de pago.
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
38
39
40
41
42
43
44
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
38
39
40
41
42
43
44
import java.util.Scanner;
public class DescuentosPorTipoDeEquipo {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int tipo_de_equipo;
double cantidad, descuento, importe_a_pagar, precio, subtotal;
String nombre_del_cliente;
System.out.print("Ingresa el nombre del cliente: ");
nombre_del_cliente = in.nextLine();
System.out.print("Ingresa el valor de cantidad: ");
cantidad = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de precio: ");
precio = in.nextDouble();
in.nextLine();
System.out.println("Selecciona el valor de tipo de equipo.");
System.out.println("\t1.- Laptop");
System.out.println("\t2.- M\u00F3vil");
System.out.println("\t3.- Tablet");
System.out.print("\t: ");
do {
tipo_de_equipo = in.nextInt();
in.nextLine();
if (tipo_de_equipo<1||tipo_de_equipo>3)
System.out.print("Valor incorrecto. Ingr\u00E9salo nuevamente.: ");
} while (tipo_de_equipo<1||tipo_de_equipo>3);
subtotal=precio*cantidad;
descuento=0;
if(cantidad>=4&&tipo_de_equipo==1)
descuento=subtotal*0.15;
if(cantidad>=4&&tipo_de_equipo==2)
descuento=subtotal*0.1;
if(cantidad>=4&&tipo_de_equipo==3)
descuento=subtotal*0.12;
importe_a_pagar=subtotal-descuento;
System.out.println("Nombre del cliente: " + nombre_del_cliente);
System.out.println("Valor de descuento: " + descuento);
System.out.println("Valor de importe a pagar: " + importe_a_pagar);
System.out.println("Valor de subtotal: " + subtotal);
}
}
public class DescuentosPorTipoDeEquipo {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int tipo_de_equipo;
double cantidad, descuento, importe_a_pagar, precio, subtotal;
String nombre_del_cliente;
System.out.print("Ingresa el nombre del cliente: ");
nombre_del_cliente = in.nextLine();
System.out.print("Ingresa el valor de cantidad: ");
cantidad = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de precio: ");
precio = in.nextDouble();
in.nextLine();
System.out.println("Selecciona el valor de tipo de equipo.");
System.out.println("\t1.- Laptop");
System.out.println("\t2.- M\u00F3vil");
System.out.println("\t3.- Tablet");
System.out.print("\t: ");
do {
tipo_de_equipo = in.nextInt();
in.nextLine();
if (tipo_de_equipo<1||tipo_de_equipo>3)
System.out.print("Valor incorrecto. Ingr\u00E9salo nuevamente.: ");
} while (tipo_de_equipo<1||tipo_de_equipo>3);
subtotal=precio*cantidad;
descuento=0;
if(cantidad>=4&&tipo_de_equipo==1)
descuento=subtotal*0.15;
if(cantidad>=4&&tipo_de_equipo==2)
descuento=subtotal*0.1;
if(cantidad>=4&&tipo_de_equipo==3)
descuento=subtotal*0.12;
importe_a_pagar=subtotal-descuento;
System.out.println("Nombre del cliente: " + nombre_del_cliente);
System.out.println("Valor de descuento: " + descuento);
System.out.println("Valor de importe a pagar: " + importe_a_pagar);
System.out.println("Valor de subtotal: " + subtotal);
}
}