• Lenguaje

    Java usando Scanner

  • Descripción

    Calcule el total de la compra de 10 productos.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.util.Scanner;

public class TotalDe10Productos {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int i;
        double costo_del_producto, total;
        total = 0;
        for (i=1; i<=10; i++) {
            System.out.print("PROCESO " + i);
            System.out.print("Ingresa el valor de costo del producto: ");
            costo_del_producto = in.nextDouble();
            in.nextLine();
            total=total+costo_del_producto;
            System.out.println();
        }
        System.out.println("Valor de total: " + total);
    }

}