It is requested to develop the algorithm that allows to analyze the behavior of the sales of the "La sweetzuela" ice cream shop.
For this, it is requested to enter a sample of 5 sales during a period of time.
You must enter:
a. Ice cream size:
i. c (Small glass)
ii. m (Medium glass)
iii. g (Cucurucho)
b. Quantity
c. Price
It must be calculated:
a. Total amount sold
b. Average amount per sale
c. Order of presentations based on sales (What size of ice cream is sold more, which less, and which is in the middle)
My problem is that when I enter vaso chico
or vaso mediano
, I get Error
(the default value of the switch), but when I input cone this does not happen and I can not find the error.
int ventas = 6;
String helados = " ";
int cantidad1 = 0;
int cantidad2 = 0;
int cantidad3 = 0;
int precio1 = 20;
int precio2 = 30;
int precio3 = 15;
int total1 = 0;
int total2 = 0;
int total3 = 0;
int totalVendido = 0;
double promedioVenta = 0;
int cantidad = 0;
Scanner teclado = new Scanner(System.in);
for (int i = 1; i < ventas; i++) { //El contador empieza desde el 1 hasta menor al valor de ventas
System.out.println(i + ".Ingrese tamaño de helado (vaso chico / vaso mediano / cucurucho) : ");
helados = teclado.next();
switch (helados) {
case "vaso chico":
System.out.println(i + ".Ingrese Cantidad : ");
cantidad = teclado.nextInt();
total1 = precio1 * cantidad;
cantidad3++;
System.out.println("Total : " + total1);
break;
case "vaso mediano":
System.out.println(i + ".Ingrese Cantidad : ");
cantidad = teclado.nextInt();
total2 = precio2 * cantidad;
cantidad2++;
System.out.println("Total : " + total2);
break;
case "cucurucho":
System.out.println(i + ".Ingrese Cantidad : ");
cantidad = teclado.nextInt();
total3 = precio3 * cantidad;
cantidad3++;
System.out.println("Total : " + total3);
break;
default:
System.out.println("Error!");
break;
}
}
totalVendido = cantidad1 + cantidad2 + cantidad3;
System.out.println("Importe total vendido : " + totalVendido);
promedioVenta = totalVendido / 5;
System.out.println("Importe promedio por venta : " + promedioVenta);
if (cantidad1 > cantidad2 && cantidad2 > cantidad3) {
System.out.println("1°.Vaso Chico . \n 2°.Vaso Mediano . \n 3°.Cucurucho .");
}
else if (cantidad2 > cantidad3 && cantidad3 > cantidad1) {
System.out.println("1°.Vaso Mediano . \n 2°.Cucurucho . \n 3°.Vaso Chico .");
}
if (cantidad3 > cantidad1 && cantidad1 > cantidad2) {
System.out.println("1°.Cucurucho . \n 2°.Vaso Chico . \n 3°.Vaso Mediano .");
}