public static void main(String[] args) {
// TODO code application logic here
Scanner lectura = new Scanner(System.in);
Producto p[] = new Producto[5];
Map<Character, Integer> categorias = new HashMap();
String nombre = "";
int precio = 0;
int total = 0;
char categoria = ' ';
for (int i = 0; i < p.length; i++) {
System.out.println("Ingrese el nombre del producto");
nombre = lectura.nextLine();
System.out.println("Ingrese el precio");
precio = lectura.nextInt();
System.out.println("Ingrese la categoría");
categoria = lectura.next().charAt(0);
lectura.nextLine();
p[i] = new Producto(nombre, precio, categoria);
categorias.put(categoria, categorias.containsKey(categoria) ? (categorias.get(categoria) + precio) : precio);
total += precio;
}
for (int i = 0; i < p.length; i++) {
System.out.println(p[i].getNombre() + " " + p[i].getPrecio() + " " + p[i].getCategoria());
}
categorias.forEach((k, v) -> {
System.out.println("Categoria " + k + ": " + v);
});
System.out.println("Total: " + total);
}