• Lenguaje

    Java usando Scanner

  • Descripción

    Para ingresar a un evento hay tres tipos de boletos o tickets: General, Oro y Diamante, se debe ingresar el valor de cada uno de estos, se requiere conocer:
    a. El número de boletos o tickets vendidos de tipo general.
    b. El número de boletos o tickets vendidos de tipo oro.
    c. El número de boletos o tickets vendidos de tipo diamante.
    d. El total de los boletos o tickets vendidos.
    e. El valor total de los boletos de tipo general vendidos.
    f. El valor total de los boletos de tipo oro vendidos.
    g. El valor total de los boletos de tipo diamantes vendidos.
    h. El valor total de los boletos o tickets vendidos.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import java.util.Scanner;

public class BoletosDeUnEvento {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a, b, c, d, tipo_de_boleto;
        double e, f, g, h, ticket_diamante;
        double ticket_general, ticket_oro;
        String tecla_repetir;
        a = 0;
        b = 0;
        c = 0;
        d = 0;
        e = 0;
        f = 0;
        g = 0;
        h = 0;
        System.out.print("Ingresa el valor de ticket diamante: ");
        ticket_diamante = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de ticket general: ");
        ticket_general = in.nextDouble();
        in.nextLine();
        System.out.print("Ingresa el valor de ticket oro: ");
        ticket_oro = in.nextDouble();
        in.nextLine();
        do {
            System.out.println("Selecciona el valor de tipo de boleto.");
            System.out.println("\t1.- General");
            System.out.println("\t2.- Oro");
            System.out.println("\t3.- Diamante");
            System.out.print("\t: ");
            do {
                tipo_de_boleto = in.nextInt();
                in.nextLine();
                if (tipo_de_boleto<1||tipo_de_boleto>3)
                    System.out.print("Valor incorrecto. Ingr\u00E9salo nuevamente.: ");
            } while (tipo_de_boleto<1||tipo_de_boleto>3);
            if(tipo_de_boleto==1)
            {
                a=a+1;
                e=e+ticket_general;
            }
            if(tipo_de_boleto==2)
            {
                b=b+1;
                f=f+ticket_oro;
            }
            if(tipo_de_boleto==3)
            {
                b=b+1;
                g=g+ticket_diamante;
            }
            System.out.println();
            do {
                System.out.print("\u00BFDeseas repetir el proceso? (S/N): ");
                tecla_repetir = in.nextLine();
            } while (!tecla_repetir.equalsIgnoreCase("s") && !tecla_repetir.equalsIgnoreCase("n"));
        } while (tecla_repetir.equalsIgnoreCase("s"));
        d=a+b+c;
        h=e+f+g;
        System.out.println("Valor de a: " + a);
        System.out.println("Valor de b: " + b);
        System.out.println("Valor de c: " + c);
        System.out.println("Valor de d: " + d);
        System.out.println("Valor de e: " + e);
        System.out.println("Valor de f: " + f);
        System.out.println("Valor de g: " + g);
        System.out.println("Valor de h: " + h);
    }

}