Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sentencia;
- public class EjemploIF2 {
- public void logica() {
- int x = (int) (Math.random() * 20.0);
- if (aprobar(x)) {
- System.out.println("Su Nota es : " + x);
- System.out.println("Aprueba, muy bien ");
- }else {
- System.out.println("Su Nota tiene oportunidades de mejora: " + x);
- System.out.println("Lamentablemente desaprueba :v");
- }
- }
- public boolean aprobar(int x) {
- boolean aprueba = false;
- if ( x >= 11)
- aprueba = true;
- return aprueba;
- }
- public static void main(String[] argus) {
- System.out.println("Dentro del main");
- EjemploIF2 objIf = new EjemploIF2();
- objIf.logica();
- }
- }
- ------------------
- package sentencia;
- import java.util.Scanner;
- public class Input01 {
- public static void main(String[] args) {
- Input01 ej = new Input01();
- ej.logica(); //Eclipse
- }
- public void logica() {
- Scanner sc = new Scanner(System.in);
- for (int i = 1; i < 3; i++) {
- System.out.println("Ingrese un numero entero");
- int numero = sc.nextInt();
- if (numero%2 == 0)
- System.out.println("El numero es Par");
- else
- System.out.println("El numero es ImPar");
- }
- }
- }
- -----------
- package sentencia;
- import java.util.Scanner;
- public class Input02 {
- public static void main(String[] args) {
- Input02 ej02 = new Input02();
- ej02.logica();
- }
- public void logica() {
- Scanner sc = new Scanner(System.in);
- System.out.println("Ingrese su Nombre ");
- String linea = sc.nextLine();
- System.out.println("Longitud \t"+linea.length() );
- System.out.println("Mayusculas \t"+linea.toUpperCase());
- System.out.println("Minusculas \t"+linea.toLowerCase());
- System.out.println("Quitar blancos \t"+linea.trim());
- System.out.println("Concatenar \t"+linea.concat("Hola"));
- System.out.println("Indexof \t"+linea.indexOf("Renzo"));
- if (linea.contentEquals("Renzo Castillo"))
- System.out.println("Los Strings son identicos");
- for (int i = 0; i < linea.length(); i++) {
- System.out.println(linea.substring(i,i+1));
- }
- for (int i = linea.length(); i > 0; i--) {
- System.out.println(linea.substring(i-1,i));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement