Mostrando entradas con la etiqueta programacion. Mostrar todas las entradas
Mostrando entradas con la etiqueta programacion. Mostrar todas las entradas

TAREA 1

TAREA 1

package camilo;

import java.util.Scanner;
public class Camilo {

   
    public static void main(String[] args) {
       
       
        String unidades[] =
        {"cero", "uno", "dos" ,"tres" ,"cuatro" ,"cinco" ,
            "seis" ,"siete" ,"ocho" ,"nueve","diez"};
        String especiales[] =
        {"once", "doce","trece","catorce", "quince",
            "diezciseis", "diecisiete", "dieciocho", "diecinueve"};
        String decenas[] =
        {"veinte", "treinta","cuarenta","cincuenta", "sesenta",
            "setenta", "ochenta", "noventa"};
                           
        Scanner scanner = new Scanner(System.in);
        System.out.print("Ingrese un numero entre 0-99: ");
        int num = scanner.nextInt();
       
        if(num>=0 && num<11)
             System.out.print('\n' + unidades[num]);       
        else if(num<20)
            System.out.print('\n' + especiales[num-11]);       
         else if(num<100){
            int unid = num % 10;
            int dec = num/10;
            if(unid == 0)
                System.out.print('\n' + decenas[dec-2]);               
            else
                System.out.print('\n' + decenas[dec-2]
                                       + " y " + unidades[unid]);
        }
        else           
            System.out.print("El numero debe ser menor a 100");
  }   
}
   

EJERCICIO DO WHILE

EJERCICIO DO WHILE
Un programa que solicite por teclado 2 numeros enteros, hacer el promedio, suma, resta, multiplicacion.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package otro;
import java.util.Scanner;

/**
 *
 * @author 305
 */
public class Otro {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
     Scanner teclado = new Scanner(System.in);
     int suma,cantidad,valor,promedio, resta;
   
     suma=0;
     cantidad=0;
     resta=0;
   
     do {
     System.out.println("Ingrese el valor:");
     valor=teclado.nextInt();
     if (valor!=0){
         suma=suma+valor;
         resta=resta-valor;
         cantidad++;
     }
   
   
     }
   
     while (valor!=0);
     if (cantidad!=0){
     promedio=(suma/cantidad);
     resta=promedio-valor;
   
 
     System.out.println("el promedio es "+promedio);
   
     System.out.println("la suma  es "+suma);
     System.out.println("la resta  es "+resta);
   

     }
     else {
     System.out.println("No dio mas valores");}
   
   
   
}
}

Estructura repetitiva DO WHILE

Esta estructura ejecuta al menos una vez el bloque repetitivo a diferencia del while o del for, esta estructura repetitiva se utiliza cuando conocemos de antemano que una vez se ejecutara el bloque
la condición de la estructura esta abajo del bloque a repetir a diferencia del while o del for que están en la parte superior



EJERCICIO PRACTICO

escriba un programa que solicite un numero entero entre 0 y 999, 
y nos muestre un mensaje de cuantos digitos tiene el mismo, 
el programa termina cuando ingrese 0.


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package programa;
import java.util.Scanner;

/**
 *
 * @author 305
 */
public class Programa {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

            Scanner teclado = new Scanner(System.in);
            int valor;
            do {
            System.out.println("Ingrese el valor entre 0 y 99999:");
            valor=teclado.nextInt();
            if (valor>1000 && valor<=99999) {
                System.out.println("tiene 5 digitos");
            } 
            
            if (valor>1000 && valor<=9999) {
                System.out.println("tiene 4 digitos");
            } 
            
            if (valor>100 && valor<=999) {
                System.out.println("tiene 3 digitos");
            } 
            
            if (valor>10 && valor<=99) {
                System.out.println("tiene 2 digitos");
            } 
            
             if (valor <= 9) {
                System.out.println("tiene 1 digitos");
            } 
            
            
            
               
            }
      
             while(valor!=0);
          
          
 }  
}



SUMA D 10 VALORES Y PROMEDIO JAVA - CICLO WHILE

SUMA D 10 VALORES Y PROMEDIO JAVA - CICLO WHILE
import java.util.Scanner;


public class EstructuraRepetitivaDoWhile2 {
    public static void main(String[] ar) {
        Scanner teclado=new Scanner(System.in);
        int x,suma,valor,promedio;
        x=1;
        suma=0;
        while(x<=10){
        System.out.println("Ingrese el valor");
        valor=teclado.nextInt();
        suma=suma+valor;
        x=x+1;}
        promedio=suma/10;
        System.out.println("La suma es igual a:");
        System.out.println(suma);
        System.out.println("El promedio es igual a:");
        System.out.println(promedio);
       
       
     
       
       
    }
}

PSEUDOCODIGO O PRUEBA DE ESCRITORIO

PSEUDOCODIGO O PRUEBA DE ESCRITORIO
Obtener un dato inicial
solicitar un dato inicial
requerir un dato de enrada

leer <datos>

ESTRUCTURA

Son procesos calculos y comparaciones que se hallaran para encontrar la solucion

- Operar sobre el dato obtenido nuevo valor
- Procesar los datos ----- obteniendo un nuevo valor

< NUEVO VALOR> ___________________________ <EXPRESION DE CALCULOS>

^DATO TRANSFORMADO   _____________________ OPERACION SOBRE EL DATO ^

ESCRITURA

- MOSTRAR EL RESULTADO
- VISUALIZAR EL RESULTADO
- IMPRIMIR EL VALOR RESULTANTE

ESCRIBIR <VALOR RESULTANTE>


EJEMPLO


Se desea calcular la distancia recorrida por un móvil con velocidad constante durante un tiempo, considerar que es un movimiento rectilíneo uniforme.

- INICIO
- TIEMPO
- VELOCIDAD CONSTANTE
- SALIDA DISTANCIA
- FIN

//------------------------------------------------------------------------//

Identificadores: son variables que van a tener un valor, que se asignan para poder hallar la solución.
variables: son las letras o las palabras que se le dan al valor que usted asigne


Clase 22/04/2017 Programación

Clase 22/04/2017 Programación
import random as x
import numpy as xx
n = int(input("ingresa el tamaño del sistema cuadrado : "))
arreglito = xx.zeros((n,n))
print ("este es el sistema\n",arreglito)
for i in range(n):
    for j in range(n):
        print ("estoy en la fila",i,"y columna",j)
        arreglito [i][j] = x.randint(1,200)
    print("asi va el arreglo \n",arreglito)  

---------------------------------------------------

import random as x
import numpy as xx
n = int(input("ingresa el tamaño del sistema cuadrado : "))
arreglito = xx.zeros((n,n))
print ("este es el sistema\n",arreglito)
for i in range(n):
    for j in range(n):
        print ("estoy en la fila",i,"y columna",j)
        arreglito [i][j] = x.randint(1,200)
print("asi va el arreglo \n",arreglito)  

----------------------------------------------
import numpy as loco
nf = int(input("ingresa el numero de filas: "))
nc = int(input("ingresa el numero de columnas: "))
arreglon = loco.zeros((nf,nc))
for f in range(nf):
    for c in range(nc):
        print("el dato sera almacenado en la flia",f,"columna",c)
        arreglon[f][c] = float(input("ingresa tu dato: "))
print("este es el arreglo\n",arreglon)

       

ejercicio python matrices

ejercicio python matrices
import numpy as np
import random as rn

var = int(input('Inserte un  número: '))
sist = np.zeros((var, var))
count = 0

for x in sist :
    for index, val in enumerate(x) :
        num = rn.randint(0, 100)
        x[index] = num
        if num % 2 == 0 :
            count = count + 1

print(sist)
print(count)

Ciclo While

Ciclo While
Es un ciclo que repite el bloque de instrucciones mientras se cumpla la condicion a evaluar

While (Condicion)_
 -
 -
 -
 -
 -
 -

Fuera de ciclo
-
-
Ejercicio 1

print("hola cabron")
Num=int(input("Ingresa un numero mayor a cero (0) "))
while(Num>0):
 Num=int(input("Ingresa un valor mayor a cero (0) "))
print ("No le dije que mayores a cero ;@")

OPERACIONES LOGICAS

OPERACIONES LOGICAS
NOT : Negacion
OR: Suma
AND: Multiplicacion
XOR: OR EXCLUSIVA

SISTEMAS

DIGITALES - COMPUTADOR  - BINARIO - 2 SIMBOLOS
DECIMAL - NOSOTROS - 10 SIMBOLOS
OCTAL - PRIMEROS PROGRAMADORES - 8 SIMBOLOS
HEXADECIMAL - 16 SIMBOLOS


PASAR DE DECIMAL A BINARIO

23 - BINARIO = SE DIVIDEN POR 2 Y SE SELECCIONAN LOS RESIDUOS  EN SENTIDO CONTRARIO

PASAR DE DECIMAL A BINARIO

CADA DIGITO SE MULTIPLICA  EN BASE 10 elevado a la cantidad de  digitos por cada uno, empezando desde la derecha elevado a la 0

INTRODUCCION A LA PROGRAMACION - Clase 3

INTRODUCCION A LA PROGRAMACION  - Clase 3

EJERCICIOS

1. SPYDER PHTYTON: CALCULAR PROMEDIOS

# -*- coding: utf-8 -*-
print ("promedio de 3 notas")
pn = float(input("Dame tu primera mala nota"))
sn = float(input("Dame tu segunda mala nota"))
tn = float(input("Dame tu tercera mala nota"))
prom = (pn+sn+tn)/3
print ("el promedio de las notas es = ",prom)


2 CALCULAR SI EL VALOR ES PAR O IMPAR
print ("Hola, Hola")
num = int(input("Ingrese un numero entero"))
if (num%2)== 0:
   print ("el numero ingresado es par")
else:
   print ("El numero ingresado es impar")
   print ("¡Listo!, acabamos")




3. mostrar el promedio de 3 notas, pero si  alguna nota es mayor a 5, el programa valida que las notas no deben ser superiores a 5

print ("promedio de 3 notas")
pn = float(input("Dame tu primera mala nota"))
sn = float(input("Dame tu segunda mala nota"))
tn = float(input("Dame tu tercera mala nota"))
prom = (pn+sn+tn)/3
print ("el promedio de las notas es = ",prom)


if (prom) < 5:
   print ("es el promedio de este semestre")
else:
   print ("El promedio no debe superior a 5, error")
   print ("ingrese valores inferiores a 5")

4. detectar los # mayores a 100 y menores a 10

menores = 0
mayores = 0

print ("ingrese 5 digitos.")

d1 = float(input("Digite el primer numero"))
d2 = float(input("Digite el segundo numero"))
d3 = float(input("Digite el tercer numero"))
d4 = float(input("Digite el cuarto numero"))
d5 = float(input("Digite el quinto numero"))

if d1 > 100:
   mayores = mayores + 1
if d1 < 10:
   menores = menores + 1
if d2 > 100:
   mayores = mayores + 1
if d2 < 10:
   menores = menores + 1
if d3 > 100:
   mayores = mayores + 1
if d3 < 10:
   menores = menores + 1
if d4 > 100:
   mayores = mayores + 1
if d4 < 10:
   menores = menores + 1
if d5 > 100:
   mayores = mayores + 1
if d5 < 10:
   menores = menores + 1

if mayores == 0:
      if menores == 0:
          print ("No hay numeros en ese rango")
if mayores > 0:
     print ("Numeros mayores a 100 hay:", mayores)
   
if menores > 0:
     print ("Numeros menores a 10 hay:", menores)
   




Clase 2

Clase 2
PROGRAMACIÓN PHYTON

print ("Hola, vamos a hallar el promedio academico de las siguientes materias: Base de datos, Programacion, Ingles y matematicas")

m = float(input ("nota Matematicas"))
b = float(input ("nota Base de datos"))
i = float(input("nota ingles"))
p = float(input ("nota programacion"))

promedio = m*0.2+b*0.2+i*0.2+p*0.4

print ("listo, el promedio es", promedio)