UNA HERMOSA MOTO

UNA HERMOSA MOTO

miércoles, 22 de abril de 2015

Problema Propuesto 14



14.- DADO UN NUMERO ENTERO DEVOLVER EL DOBLE DEL NUMERO SI EL NUMERO ES POSITIVO, EL TRIPLE SI ES NEGATIVO Y CERO SI ES NEUTRO.


Resultado de imagen para POSITIVO

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package propuesto014;
import java.util.Scanner;
/**
 *
 * @author abel montalvan
 */
public class Propuesto014 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        int a,b;
           

            Scanner teclado=new Scanner(System.in);
            System.out.print("ESCRIBIR UN NÚMERO:");
            a=teclado.nextInt();
           
            //PROCESO
            if (a>0){
                  b=a*2;
            }else{
            if (a<0){
                  b=a*3;
            }else{
                  b=0;
            }
            }
            System.out.println("");
            System.out.println("EL RESULTADO ES: "+b);
            }
      }

No hay comentarios:

Publicar un comentario