// SEMANA 2 PREGUNTA 3
// Desarrolle la aplicación Factura2App, la cual mejora Factura1App: usa bigDecimal con
// dos decimales y formatea los datos. Ejemplo de salida
//
// Compra
// Ingrese nombre artículo: Lapicero
// Ingrese Precio : 2.5
// Ingrese Cantidad : 4
// Factura
// Precio Cantidad Soles
// 2.50 4 10.00
// Descuento 10%": 1.00
// Total compra : 9.00
// IGV: 18% : 1.62
// Total Factura : 10.62
import java.util.Scanner;
import java.text.NumberFormat;
import java.math.BigDecimal;
public class Factura2App{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
NumberFormat numero = NumberFormat.getNumberInstance();
numero.setMinimumFractionDigits(2);
numero.setMaximumFractionDigits(2);
NumberFormat porc = NumberFormat.getPercentInstance();
final BigDecimal DESCUENTO = new BigDecimal(.1), IGV = new BigDecimal(.18);;
String articulo;
int cantidad;
BigDecimal precio, soles, descuento, igv;
System.out.println("Compra");
System.out.print("\tIngrese nombre artículo: ");
articulo = sc.next();
System.out.print("\tIngrese Precio : ");
precio = new BigDecimal(sc.nextDouble());
System.out.print("\tIngrese Cantidad : ");
cantidad = sc.nextInt();
System.out.println("\nFactura");
System.out.println("\tPrecio Cantidad Soles");
soles = precio.multiply(new BigDecimal(cantidad));
System.out.printf("\t%5s\t %4d%11s\n", numero.format(precio), cantidad, numero.format(soles));
System.out.printf("\n\tDescuento %s", porc.format(DESCUENTO));
descuento = DESCUENTO.multiply(soles);
System.out.printf(" : %11s\n", numero.format(descuento));
soles = soles.subtract(descuento);
System.out.printf("\tTotal compra : %11s\n", numero.format(soles));
System.out.printf("\tIGV: %s : ", porc.format(IGV));
igv = IGV.multiply(soles);
System.out.printf("%11s\n", numero.format(igv));
soles = soles.add(igv);
System.out.printf("\tTotal Factura : %11s\n", numero.format(soles));
}
}