Advertisement
rsvaco

pract5, ventaentradas

Nov 8th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.33 KB | None | 0 0
  1. import java.util.Locale;
  2. import java.util.Scanner;
  3. /** Clase VentaEntradas.
  4.  *  Practica 5 - IIP - ETSINF-UPV.
  5.  *  
  6.  *  @author
  7.  *  @version Curso 2016/17
  8.  */
  9. public class VentaEntradas {
  10.  
  11.     public static void main(String [] args) {
  12.         Scanner teclado = new Scanner(System.in).useLocale(Locale.US);
  13.        
  14.         // Lectura de los datos de la entrada
  15.         System.out.println("Caracteristicas de la entrada: ");
  16.         System.out.print("   Titulo: ");
  17.         String titulo = teclado.nextLine();
  18.         System.out.print("   Cine: ");
  19.         String cine = teclado.nextLine();
  20.         System.out.print("   Hora: ");
  21.         int hora = teclado.nextInt();
  22.         System.out.print("   Minutos: ");
  23.         int minutos = teclado.nextInt();
  24.        
  25.        
  26.         // Creacion de la Entrada
  27.         Entrada e = new Entrada(titulo, cine, hora, minutos);
  28.    
  29.         // Lectura de los datos para aplicar descuentos
  30.         // variables a utilizar inicializadas por defecto a false:
  31.         boolean diaEspec = false, festivo = false,
  32.                 vispera = false, tCliente = false;
  33.                
  34.         System.out.print("Edad? ");
  35.         int edad = teclado.nextInt(); teclado.nextLine();
  36.        
  37.         System.out.print("Es el dia del espectador? (SI/NO) ");
  38.         String res = teclado.next().toUpperCase();
  39.         if (res.equals("SI")) { diaEspec = true; }
  40.         System.out.print("Es un dia festivo? (SI/NO) ");
  41.         res = teclado.next().toUpperCase();
  42.         if (res.equals("SI")) { festivo = true; }
  43.         System.out.print("Mañana es un dia festivo? (SI/NO) ");
  44.         res = teclado.next().toUpperCase();
  45.         if (res.equals("SI")) { vispera = true; }
  46.         System.out.print("Tarjeta cliente? (SI/NO) ");
  47.         res = teclado.next().toUpperCase();
  48.         if (res.equals("SI")) { tCliente = true; }
  49.        
  50.         /* A COMPLETAR: Lectura de RESTO de datos para aplicar DESCUENTOS */
  51.        
  52.  
  53.         // Calculo del precio final de la Entrada e,
  54.         // invocando al metodo precioFinal
  55.         double pFin = e.precioFinal(edad, diaEspec, festivo, vispera, tCliente);
  56.                      
  57.    
  58.         // Mostrar por pantalla el precio final
  59.         System.out.println("El precio final para la entrada es: "
  60.             + String.format("%.2f", pFin) + " euros");
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement