Trabajo de Lenguaje de Programacion

5
““Año de la Diversificación Productiva y del Fortalecimiento de la Educación”UNIVERSIDAD NACIONAL DEL SANTA FACULTAD DE INGENIERÍA ESCUELA ACADÉMICA PROFESIONAL INGENIERÍA MECÁNICA I UNIDAD ASIGANTURA : Lenguaje de Programación DOCENTE : Ing. Reyna Rojas INTEGRANTES : - Vargas Haro Gary Junior EAP. Ingeniería Mecánica Página 1

description

wqddwdwqw

Transcript of Trabajo de Lenguaje de Programacion

Page 1: Trabajo de Lenguaje de Programacion

““Año de la Diversificación Productiva y del Fortalecimiento de la Educación””

UNIVERSIDAD NACIONAL DEL SANTAFACULTAD DE INGENIERÍA

ESCUELA ACADÉMICA PROFESIONALINGENIERÍA MECÁNICA

I UNIDAD

ASIGANTURA : Lenguaje de Programación

DOCENTE : Ing. Reyna Rojas

INTEGRANTES :

- Vargas Haro Gary Junior

CICLO :

Nuevo Chimbote, 26 septiembre de 2015

EJERCICIO 10:

EAP. Ingeniería Mecánica Página 1

Page 2: Trabajo de Lenguaje de Programacion

package conductor.de.coche;

import javax.swing.*;

import java.text.*;

/**

*

* @author junior

*/

public class ConductorDeCoche {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

String txt1 = "", txt2 = "", txt3 = "", txt4 = "";

String modelo[] = {"A","B"};

String color[] = {"Blanco","Metalizado","Otros"};

DecimalFormat miformato = new DecimalFormat("###,###,###.##");

int edad = 0, pase = 0;

double incremE = 0.0, incremP = 0.0, precpase = 0, veuroapeso = 3225.86, total = 0.0, subtotal = 0.0;

//Captura de datos

txt1 = (String)JOptionPane.showInputDialog(null, "Modelo", "Seguro Obligatorio",

JOptionPane.QUESTION_MESSAGE, null, modelo, modelo[modelo.length-1]);

txt2 = (String)JOptionPane.showInputDialog(null, "Color", "Seguro Obligatorio",

JOptionPane.QUESTION_MESSAGE, null, color, color[color.length-1]);

txt3 = JOptionPane.showInputDialog(null, "Ingrese la edad",

EAP. Ingeniería Mecánica Página 2

Page 3: Trabajo de Lenguaje de Programacion

"Seguro Obligatorio", JOptionPane.INFORMATION_MESSAGE);

txt4 = JOptionPane.showInputDialog(null, "Hace cuanto tiempo saco el pase",

"Seguro Obligatorio", JOptionPane.INFORMATION_MESSAGE);

//Convertir datos de String a Integer(Entero)

edad = Integer.parseInt(txt3);

pase = Integer.parseInt(txt4);

//Verificamos datos

if(pase >= 26 && edad <= 30){

incremE = 0.25;

}else if(edad > 65){

incremE = 0.10;

}

if(txt1 == "A"){

if(txt2 == "Blanco"){

precpase = 240.41;

}

if(txt2 == "Metalizado"){

precpase = 330.00;

}

if(txt2 == "Otros"){

precpase = 270.50;

}

}else if(txt1 == "B"){

if(txt2 == "Blanco"){

precpase = 300.00;

EAP. Ingeniería Mecánica Página 3

Page 4: Trabajo de Lenguaje de Programacion

}

if(txt2 == "Metalizado"){

precpase = 360.50;

}

if(txt2 == "Otros"){

precpase = 330.00;

}

}

//Realizamos las operaciones

subtotal = (precpase * veuroapeso) * incremP;

total = (precpase * veuroapeso) * incremE;

total = (precpase * veuroapeso) + total + subtotal;

//Imprimimos los resultados

JOptionPane.showMessageDialog(null, "Total a pagar por el Seguro Obligatorio: $ " + miformato.format(total),

"Seguro Obligatorio", JOptionPane.INFORMATION_MESSAGE);

}}

EAP. Ingeniería Mecánica Página 4