It is requested to develop the algorithm that allows to analyze the behavior of the sales of the Ice cream shop "La dulzura"
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)
* When I enter: small glass or medium glass, I get an error, but when I get a cone, 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++) {
System.out.println(i + ".Ingrese tamaño de helado (vaso chico / vaso mediano / cucurucho) : ");
helados = teclado.next();
System.out.println(i + ".Ingrese Cantidad : ");
cantidad = teclado.nextInt();
switch (helados) {
case "vaso chico ":
total1 = precio1 * cantidad;
cantidad1++;
System.out.println("Total : " + total1);
break;
case "vaso mediano ":
total2 = precio2 * cantidad;
cantidad2++;
System.out.println("Total : " + total2);
break;
case "cucurucho":
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 .");
}