-
Lenguaje
Java usando Scanner
-
Descripción
María compró 3 productos, donde tiene que aumentar el 16% de IVA al total de la compra, muestra el subtotal, cuanto va a pagar de IVA y el total a pagar.
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
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 CompraDeMaria {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double IVA, precio_del_producto_1, precio_del_producto_2, precio_del_producto_3, subtotal;
double total_a_pagar;
System.out.print("Ingresa el valor de precio del producto 1: ");
precio_del_producto_1 = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de precio del producto 2: ");
precio_del_producto_2 = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de precio del producto 3: ");
precio_del_producto_3 = in.nextDouble();
in.nextLine();
subtotal=precio_del_producto_1+precio_del_producto_2+precio_del_producto_3;
IVA=subtotal*0.16;
total_a_pagar=subtotal+IVA;
System.out.println("Valor de IVA: " + IVA);
System.out.println("Valor de subtotal: " + subtotal);
System.out.println("Valor de total a pagar: " + total_a_pagar);
}
}
public class CompraDeMaria {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double IVA, precio_del_producto_1, precio_del_producto_2, precio_del_producto_3, subtotal;
double total_a_pagar;
System.out.print("Ingresa el valor de precio del producto 1: ");
precio_del_producto_1 = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de precio del producto 2: ");
precio_del_producto_2 = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de precio del producto 3: ");
precio_del_producto_3 = in.nextDouble();
in.nextLine();
subtotal=precio_del_producto_1+precio_del_producto_2+precio_del_producto_3;
IVA=subtotal*0.16;
total_a_pagar=subtotal+IVA;
System.out.println("Valor de IVA: " + IVA);
System.out.println("Valor de subtotal: " + subtotal);
System.out.println("Valor de total a pagar: " + total_a_pagar);
}
}