Ecchijpbp

Programacion pre Parcial 2

May 4th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace Viaje
  12. {
  13. public partial class Form1 : Form
  14. {
  15. double cInternacional = 0;
  16. double cNacional = 0;
  17. double cViajes = 0;
  18. int cTren = 0;
  19. int cBarco = 0;
  20. int c160;
  21. double aPrecios;
  22. Viaje m = new Viaje();
  23.  
  24. public Form1()
  25. {
  26. InitializeComponent();
  27. }
  28.  
  29. private void cmdRegistrar_Click(object sender, EventArgs e)
  30. {
  31. Viaje v = new Viaje();
  32. v.pCodigo = Convert.ToInt32(txtCodigo.Text);
  33. v.pDestino = txtDestino.Text;
  34. v.pFecha = dtpFecha.Value;
  35. v.pPrecio = Convert.ToDouble(txtPrecio.Text);
  36. if (v.pPrecio > 160)
  37. {
  38. c160++;
  39. lblPrecioViajes.Text = Convert.ToString(c160);
  40. }
  41. aPrecios += v.pPrecio;
  42. if (rbtInternacional.Checked)
  43. {
  44. v.pTipo = 2;
  45. cInternacional++;
  46. }
  47. else
  48. {
  49. v.pTipo = 1;
  50. cNacional++;
  51. }
  52. if (cViajes == 0)
  53. {
  54. m = v;
  55. lblViajeBarato.Text = "Viaje mas Barato: " + m.pPrecio;
  56. }
  57. else
  58. if (v.pPrecio < m.pPrecio)
  59. m = v;
  60.  
  61. cViajes++;
  62. v.pTransporte = cmbTransporte.SelectedIndex + 1;
  63. if (v.pTipo == 1)
  64. {
  65. if (v.pTransporte == 2)
  66. cTren++;
  67. }
  68. else
  69. if (v.pTransporte == 4)
  70. cBarco++;
  71.  
  72. lblViajesNacionales.Text = "Viajes Nacionales: " + Convert.ToString(Math.Round(cNacional/cViajes *100,2));
  73. lblViajesInternacionales.Text = "Viajes Internacionales: " + Convert.ToString(Math.Round(cInternacional / cViajes * 100,2));
  74. lblViajesNacTren.Text = "Viajes Nacionales en Tren: " + Convert.ToString(cTren);
  75. lblViajesInterBarco.Text = "Viajes Internacionales en Barco: " + Convert.ToString(cBarco);
  76. lblViajeBarato.Text = "Viaje Mas Barato: " + m.pPrecio;
  77. lblPrecioPromedio.Text = "Precio promedio de Viajes: " + Convert.ToString(Math.Round(aPrecios / cViajes,2));
  78. MessageBox.Show(v.toStringClase());
  79. }
  80. }
  81. }
Add Comment
Please, Sign In to add comment