Lab Oratorio 3

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

import java.util.*; public class TablasinString { public static void main(String[] args) { int num,x=1,y; Scanner scan=new Scanner(System.

in); System.out.println("Ingrese su numero a multiplicar"); num=scan.nextInt(); while (x<=10){ y=num*x; System.out.println( num +"x"+ x+ " = " + y); x++; } } }

import java.util.Scanner; public class Lab3TABLAS { public static void main(String[] args) { int n; Scanner teclado = new Scanner(System.in); System.out.println("Introduce numero para ver su tabla:"); n = teclado.nextInt(); System.out.println("La tabla del "+n+" es:"); System.out.println(n+"*1 ="+ n*1); System.out.println(n+"*2 ="+ n*2); System.out.println(n+"*3 ="+ n*3); System.out.println(n+"*4 ="+ n*4); System.out.println(n+"*5 ="+ n*5); System.out.println(n+"*6 ="+ n*6); System.out.println(n+"*7 ="+ n*7); System.out.println(n+"*8 ="+ n*8);

System.out.println(n+"*9 ="+ n*9); System.out.println(n+"*10 ="+ n*10);

} }

import java.util.Scanner;

public class Potencia2 { public static void main(String[] args) { int Pot; Scanner teclado = new Scanner(System.in); System.out.println("Introduce numero:"); Pot = teclado.nextInt(); System.out.println("Tus resultados:"); for (int x=0;x<=Pot;x++) System.out.print((int)Math.pow(2,x)+" "); } }

import java.util.Scanner; public class sumaNumeros { public static void main(String[] args) { int num1,num2, suma; Scanner numero = new Scanner(System.in); System.out.println("Introduce tu primer numero:"); num1 = numero.nextInt(); System.out.println("Introduce tu segundo numero:

"); num2 = numero.nextInt(); suma = ((num2-1)*((num2-1)+1))/2 ((num1)*(num1+1))/2; System.out.println("Tu Suma es: " + suma); } }

public class TablaGrande { public static void main(String []args){ int tabl=0; for(int i=1; i<=10; i++) { for(int j=1; j<=10; j++) { tabl=i*j; if(tabl<10) System.out.print(" "+tabl);

if(tabl>=10&&tabl<100) System.out.print(" "+tabl); if (tabl<=100&&tabl>=100) System.out.print(" "+tabl); } System.out.println(); } } }

import java.util.Scanner; import javax.swing.*; public class Divisores { public static void main(String[] args) { int n,i; String div; Scanner numero = new Scanner(System.in); System.out.println("Introduce tu primer numero:"); n = numero.nextInt(); i= (n/2); div=" "+n; do{ if(n%i==0){ div+=" "+i; } i=i-1;

} while(i>0); System.out.println(div);

import java.util.*; public class Viaje { public static void main(String[] args) { int x=1,y=0,z,h; while (x>0) { Scanner tramo=new Scanner(System.in); System.out.println("Duracion tramo"); x=tramo.nextInt();

y+=x; } z=y/60; h=y%60; System.out.print(z+ ":"); if(h<10) System.out.print("0"+ h); else System.out.print(h); } }

import java.util.Scanner; public class Asteriscos { public static void main(String[] args) { int altura, ancho; Scanner teclado = new Scanner(System.in); System.out.println("Introduce Altura:"); altura = teclado.nextInt(); System.out.println("Introduce Ancho"); ancho = teclado.nextInt(); for (int x=0;x<altura;x++) { for (int y=0;y<ancho;y++) System.out.print('*'); System.out.println(""); } } }

import java.util.Scanner; public class TrianguloAsterisco { public static void main(String[] args) { int a; Scanner numero = new Scanner(System.in); System.out.println("Ingrese la altura de su Triangulo"); a=numero.nextInt(); for (int i= 1; i<=a; i++){ for(int j=1; j<=a;j++){ if( j>i){ System.out.print(" "); } else { System.out.print("*"); } } System.out.print('\n'); } } }

import import import import

java.awt.FlowLayout; java.awt.FlowLayout.*; javax.swing.*; javax.swing.JLabel.*;

public class VentanaFrame extends JFrame { private JLabel miVentana2; public VentanaFrame () { super ("El Super Titulo"); setLayout (new FlowLayout()); JFrame miVentana; miVentana2=new JLabel("Esta es mi primera oracion"); miVentana2.setToolTipText("Observa mi primer programa"); add(miVentana2); } }

import javax.swing.JFrame; class Apples { public static void main(String[] args) { VentanaFrame bucky = new VentanaFrame (); bucky.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); bucky.setSize(300,400); bucky.setVisible(true);

} }

You might also like