Estructura for y vectores

9
UNIVERSIDAD TÉCNICA DE MACHALA FACULTAD DE INGENIERÍA CIVIL ESCUELA DE INFORMÁTICA CARRERA DE INGENIERÍA EN SISTEMAS PROGRAMACION ESTRUCTURADA AUTOR: EDWIN EBER BELDUMA MOROCHO PERIODO 2013 - 2014 MACHALA EL ORO ECUADOR

Transcript of Estructura for y vectores

Page 1: Estructura for y vectores

UNIVERSIDAD TÉCNICA DE MACHALA

FACULTAD DE INGENIERÍA CIVIL ESCUELA DE INFORMÁTICA

CARRERA DE INGENIERÍA EN SISTEMAS

PROGRAMACION ESTRUCTURADA

AUTOR:

EDWIN EBER BELDUMA MOROCHO

PERIODO 2013 - 2014

MACHALA – EL ORO – ECUADOR

Page 2: Estructura for y vectores

ESTRUCTURA REPETITIVA FOR … Y VECTORES• package principal;• package casita;

• // TODO: Auto-generated Javadoc• /**• * The Class For.• */• public class For {

• /**• * The main method.• *• * @param args the arguments• */• public static void main(String[] args) {• int x []= new int [8];• for (int i = 0; i < x.length; i++) {• }• int y=15;• int tem = 0;• for (int i = 0; i < y; i++) {• tem++;

• }• System.out.println(tem );• }

• }

Page 3: Estructura for y vectores

• public class practica1 {

• /** The sc. */• static Scanner sc = new Scanner(System.in);

• /** The x. */• static int x;

• /** The y. */• static int y;

• /** The suma. */• static int suma;

• /** The resta. */• static int resta;

• /** The multiplicacion. */• static int multiplicacion;

• /** The division. */• static double division;

• /** The raiz. */• static int raiz;

• /** The cuadrado. */• static int cuadrado;

• /** The coseno. */• static int coseno;

Page 4: Estructura for y vectores

• /** The seno. */• static int seno;

• /** The m1. */• static int m1[] = new int[8];

• /** The m2. */• static int m2[][] = new int[8][8];

• /**• * The main method.• *• * @param args the arguments• */• public static void main(String[] args) {• try {

• operacion();• fort();

• } catch (Exception e) {

• }

• }

Page 5: Estructura for y vectores

• /**• * Ingreso.• */• static void ingreso() {• System.out.println("ingresasr un numero ");• x = sc.nextInt();• System.out.println("ingrese segund numero ");• y = sc.nextInt();• suma();• resta();• multiplicacion();• division();

• }

• /**• * Suma.• */• static void suma() {

• suma = x + y;• System.out.println("la suma es =" + suma);

• }

• /**• * Resta.• */• static void resta() {• resta = x - y;• System.out.println("la resta esa = " + resta);• }

Page 6: Estructura for y vectores

• /**• * The main method.• *• * @param args the arguments• */• public static void main(String[] args) {• Scanner scan = new Scanner(System.in);• double spvp = 0;• double sg = 0;• float pvp;• float ganan;• int numero = 1;• /**• * hasta que numero sea menor igual a 4 hacer las instrucciones • */• while (numero <= 4) {• System.out.println("ingrese el codigo");• int cod = scan.nextInt();• System.out.println("ingrese la descripcion del producto");• Scanner teclado = new Scanner(System.in);• String descrip;• descrip = teclado.next();• System.out.println("ingrese el modelo");• String mod;• mod = teclado.next();• System.out.println("ingrese el precio de costo");• float pc = scan.nextFloat();• ganan = (float) (pc * 0.25);• pvp = pc + ganan;• System.out.println("el precio de venta al publico es " + pvp);• sg = sg + ganan;• spvp = spvp + pvp;• numero = numero + 1;• }• System.out.println("la suma total de las ganancias es " + sg);• System.out.println("la suma total del precio deventa al publico es "• + spvp);• }

• }

Page 7: Estructura for y vectores

• /**• * Multiplicacion.• */• static void multiplicacion() {• multiplicacion = x * y;• System.out.println("la multiplicacion es " + multiplicacion);• }

• /**• * Division.• */• static void division() {• division = (double) x / y;• System.out.println("la division es =" + division);• }

• /**• * Raiz.• */• static void raiz() {

• }

• /**• * Operacion.• */• static void operacion() {• System.out.println("ingrese el primer numero ");• m1[6] = sc.nextInt();• System.out.println("ingrese el segundo numero ");• m1[5] = sc.nextInt();

• m1[4] = 15;• m1[3] = 5;• m1[2] = 6;• m1[7] = (int) Math.pow((m1[6] + m1[5]) + (m1[7] - m1[5]), 3)• / (m1[4] + m1[5] + m1[2]) - m1[3] + m1[4];• System.out.println("resultado es= " + m1[7]);

• }

Page 8: Estructura for y vectores

• /**• * Fort.• */• static void fort() {• int tem=2;• for (int i = 0; i < m2.length - 1; i++) {• for (int j = 0; j < m2[i].length; j++) {• System.out.print(m2[i][j] + " \t");• tem=tem+1;• }• System.out.println("");

• }• System.out.println(tem);• }• }

Page 9: Estructura for y vectores

•ESPERO QUE ESTAS PRACTICAS LES SIRVAN

GRACIAS ……