Sunteți pe pagina 1din 7

1.- Ingresar por teclado un nombre. Mostrarlo en pantalla en mayúsculas.

/*

* 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 ejercicio1;

import java.util.Scanner;

public class Ejercicio1 {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

System.out.println("*****Ingresar por teclado un nombre*****");

String nombre;

Scanner teclado = new Scanner(System.in);

System.out.print("Ingrese nombre: ");

nombre = teclado.nextLine();

System.out.println(nombre.toUpperCase());

}
2.- Ingresar por teclado 1 nombre y un apellido. Mostrar en pantalla: Nombre
Apellido, ambos con la primer letra en mayúsculas independientemente de como
hayan sido ingresados  No logré poner en mayúscula la primera letra.

/*

* 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 ejercicio2;

import java.util.Scanner;

public class Ejercicio2 {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

//2.- Ingresar por teclado 1 nombre y un apellido.

//Mostrar en pantalla: Nombre Apellido,

//ambos con la primer letra en mayúsculas independientemente de como hayan sido

//ingresados.

System.out.println("***Ingresar 1 nombre y 1 apellido");

String nombre;
String apellido;

Scanner teclado = new Scanner(System.in);

System.out.print("Ingrese nombre: ");

nombre = teclado.nextLine();

System.out.println(nombre);

System.out.print("Ingrese apellido: ");

apellido = teclado.nextLine();

System.out.println(apellido);

3.- Ingresar en las variables dia, mes y año una fecha. Mostrarla en pantalla con el
formato: dd-mm-aaaa

/*
* 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 ejercicio3;

import java.util.Scanner;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Ejercicio3 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//Ingresar en las variables dia, mes y año una fecha.
//Mostrarla en pantalla con el formato: dd-mm-aaaa

Date myDate = new Date();


System.out.println(myDate);
System.out.println(new SimpleDateFormat("dd-MM-yyyy").format(myDate));
System.out.println(myDate);

4.- Ingresar un nombre. Mostrar en pantalla el nombre en mayúsculas y la cantidad


de caracteres que tiene.

/*
* 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 ejercicio4;

import java.util.Scanner;

/**
*
* @author nickipc
*/
public class Ejercicio4 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//4.- Ingresar un nombre. Mostrar en pantalla el nombre en mayúsculas y la cantidad
//de caracteres que tiene.

System.out.println("****Ingresar un nombre y mostrarlo en mayusculas y cantidad de


caracteres");

String nombre;

Scanner teclado = new Scanner(System.in);

System.out.print("Ingrese nombre: ");


nombre = teclado.nextLine();
System.out.println(nombre.toUpperCase());
System.out.println("Cantidad de caracteres: " + nombre.length() + " caracteres");

}
}

5.- Ingresar por teclado un número de 4 dígitos distintos, mostrarlo en orden


inverso…

(No logré hacerlo)

6.- Ingresar por teclado 1 número entero. Mostrar en pantalla su tabla de multiplicar
entre 1 y 12 (usando la instrucción for)

/*
* 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 ejercicio6;

import java.util.Scanner;

public class Ejercicio6 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

int tabla;
Scanner teclado=new Scanner (System.in);
System.out.print("Introduce un numero entero: ");
tabla = teclado.nextInt ();

for(int var1=1;var1<=12;var1++){
System.out.println(+tabla+"x"+var1+"="+(var1*tabla));
}
}

7.- Ingresar por teclado 1 número entero. Mostrar en pantalla su tabla de multiplicar
entre 1 y 12 (usando la instrucción while)

/*
* 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 ejercicio7;

import java.util.Scanner;
public class Ejercicio7 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//Ingresar por teclado 1 número entero. Mostrar en pantalla su tabla de multiplicar entre 1
//y 12 (usando la instrucción while)

System.out.println ("****Tabla de multiplicar del 1 al 12 con instrucción While*******")

int num = 0, i =1;

Scanner teclado = new Scanner (System.in);

System.out.print("Ingrese un numero entero: ");


num = teclado.nextInt();

while(i <=12){
System.out.println(num + " * " +i+ "=" + (num*i));
i++;
}

8.- Ingresar por teclado 1 número entero. Mostrar en pantalla su tabla de multiplicar
entre 1 y 12 (usando la instrucción do while)

/*
* 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 ejercicio8;

import java.util.Scanner;

public class Ejercicio8 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

//Ingresar por teclado 1 número entero. Mostrar en pantalla su tabla de multiplicar entre 1
//y 12 (usando la instrucción do while)

System.out.println ("****Tabla de multiplicar del 1 al 12 con instrucción Do While*******")


int num = 0, i =1;

Scanner teclado = new Scanner (System.in);

System.out.print("Ingrese un numero entero: ");


num = teclado.nextInt();

do{
System.out.println(num + " * " +i+ "=" + (num*i));
i++;
}

while(i <=12){
}

S-ar putea să vă placă și