INSTITUTO TECNOLÓGICO DE CANCÚN


         INGENIERÍA MECATRÓNICA


                MATERIA:


          PROGRAMACIÓN BÁSICA


               PROFESORA:


     MARÍA JACINTA MARTÍNEZ CASTILLO


              “PROGRAMA 6”


                AUTORES:


   ALEJANDRO FIGUEROA ANDRÉS ALFONSO


         CUA MAY JOEL DE LA CRUZ


           MARTINEZ SOLIS ITZEL




CANCÚN QUINTANA ROO A 20 DE ABRIL DEL 2012
PLANTEAMIENTO DEL PROBLEMA

Escribe un programa que lea una temperatura introducida a través del teclado y
muestre por pantalla la actividad más apropiada para dicha temperatura teniendo
en cuenta los siguientes criterios.
ACTIVIDAD TEMPERATURA IDÓNEA
Natación Temp>30
Tenis20 <temp ≤ 30
Golf 10<temp<=20
Esquí5<temp<=10
Parchís Temp<=5

ANÁLISIS DEL PROBLEMA
Se analiza la temperatura y uno se pregunta de acuerdo a los criterios si es mayor,
menor o = y se determina que actividad se estuviste haciendo para obtener esa
temperatura.




                                        1
DIAGRAMA DE FLUJO




       2
PRUEBA DE ESCRITORIO

Se ingresa el valor de la temperatura luego comprobando con una serie de
decisiones que te dicen si la temperatura ingresada pertenece a alguna actividad
planteada anteriormente.

                                 Código de fuente

publicclass Temperatura {

public static void main(String[] args) {

        // TODO code application logic here

int temp=Integer.parseInt(JOptionPane.showInputDialog(null,
"Ingresatutemperatura"));

if (temp>30)

JOptionPane.showMessageDialog(null, "Estuvistenadando");

else

if ( 20<temp && temp <=30)

JOptionPane.showMessageDialog(null, "Estuvistejugandotenis");

else

if (10<temp&& temp<=20)

JOptionPane.showMessageDialog(null, "Estuvistejugando golf");

else

if (5<temp&& temp<=10)

JOptionPane.showMessageDialog(null, "Estuvistehaciendoesqui");

else

JOptionPane.showMessageDialog(null, "Estuviste jugando parchis");



    }

}




                                           3
Depuración




    4
Conclusión

En este programa se utilizan las decisiones básicas como el if pero también
algunas condiciones como && (y también) para poder comparar la temperatura.




                                      5

Programa 6

  • 1.
    INSTITUTO TECNOLÓGICO DECANCÚN INGENIERÍA MECATRÓNICA MATERIA: PROGRAMACIÓN BÁSICA PROFESORA: MARÍA JACINTA MARTÍNEZ CASTILLO “PROGRAMA 6” AUTORES: ALEJANDRO FIGUEROA ANDRÉS ALFONSO CUA MAY JOEL DE LA CRUZ MARTINEZ SOLIS ITZEL CANCÚN QUINTANA ROO A 20 DE ABRIL DEL 2012
  • 2.
    PLANTEAMIENTO DEL PROBLEMA Escribeun programa que lea una temperatura introducida a través del teclado y muestre por pantalla la actividad más apropiada para dicha temperatura teniendo en cuenta los siguientes criterios. ACTIVIDAD TEMPERATURA IDÓNEA Natación Temp>30 Tenis20 <temp ≤ 30 Golf 10<temp<=20 Esquí5<temp<=10 Parchís Temp<=5 ANÁLISIS DEL PROBLEMA Se analiza la temperatura y uno se pregunta de acuerdo a los criterios si es mayor, menor o = y se determina que actividad se estuviste haciendo para obtener esa temperatura. 1
  • 3.
  • 4.
    PRUEBA DE ESCRITORIO Seingresa el valor de la temperatura luego comprobando con una serie de decisiones que te dicen si la temperatura ingresada pertenece a alguna actividad planteada anteriormente. Código de fuente publicclass Temperatura { public static void main(String[] args) { // TODO code application logic here int temp=Integer.parseInt(JOptionPane.showInputDialog(null, "Ingresatutemperatura")); if (temp>30) JOptionPane.showMessageDialog(null, "Estuvistenadando"); else if ( 20<temp && temp <=30) JOptionPane.showMessageDialog(null, "Estuvistejugandotenis"); else if (10<temp&& temp<=20) JOptionPane.showMessageDialog(null, "Estuvistejugando golf"); else if (5<temp&& temp<=10) JOptionPane.showMessageDialog(null, "Estuvistehaciendoesqui"); else JOptionPane.showMessageDialog(null, "Estuviste jugando parchis"); } } 3
  • 5.
  • 6.
    Conclusión En este programase utilizan las decisiones básicas como el if pero también algunas condiciones como && (y también) para poder comparar la temperatura. 5