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
ESTRUCTURAREPETITIVAFOR …
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 );
• }
• }
• 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;
• /** 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) {
• }
• }
• /**
• * 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);
• }
• /**
• * 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);
• }
• }
• /**
• * 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]);
• }
• /**
• * 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);
• }
• }
•ESPERO QUE ESTAS
PRACTICAS LES SIRVAN
GRACIAS ……

Estructura for y vectores

  • 1.
    UNIVERSIDAD TÉCNICA DEMACHALA 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
  • 2.
    ESTRUCTURAREPETITIVAFOR … 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 ); • } • }
  • 3.
    • public classpractica1 { • /** 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;
  • 4.
    • /** Theseno. */ • 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) { • } • }
  • 5.
    • /** • *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); • }
  • 6.
    • /** • *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); • } • }
  • 7.
    • /** • *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]); • }
  • 8.
    • /** • *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); • } • }
  • 9.
    •ESPERO QUE ESTAS PRACTICASLES SIRVAN GRACIAS ……