Skip to content

Instantly share code, notes, and snippets.

@godie007
Created May 22, 2012 00:40
Show Gist options
  • Select an option

  • Save godie007/2765709 to your computer and use it in GitHub Desktop.

Select an option

Save godie007/2765709 to your computer and use it in GitHub Desktop.
import javax.swing.JOptionPane;
public class Ejercicio1 {
public static void main(String[] args) {
int contador = 0;
int contador2 = 0;
int importe = 0;
int users = Integer.parseInt(JOptionPane.showInputDialog("Numero de Usuarios"));
for (int i = 0; i < users; i++) {
int sueldo1 = Integer.parseInt(JOptionPane.showInputDialog("sueldo"));
boolean valido = true;
if (sueldo1 <= 300 && sueldo1 >= 100) {
contador++;
} else if (sueldo1 > 300 && sueldo1 <= 500) {
contador2++;
}
else{
JOptionPane.showMessageDialog(null, "Salario no valido");
valido = false;
}
if(valido){
importe += sueldo1;
}
}
System.out.println("A: " + contador + " B: " + contador2 +" Importe: "+importe);
}
}
public class Reloj {
public static void main(String[] args) {
int hor = 23;
int min = 59;
int seg = 59;
int in = 00;
for (int j = 0; j <= hor; j++) {
for (int j2 = 0; j2 <= min; j2++) {
for (int k = 0; k <= seg; k++) {
System.out.println("Hor: " + j + " min: " + j2 + " seg: "
+ k + " Ciclo: " + in++);
}
}
}
}
}
public class Reloj1 {
public static void main(String[] args) {
int hor = 23;
int min = 59;
int seg = 59;
int j = 0;
while (j <= hor) {
int j2 = 0;
while (j2 <= min) {
int k = 0;
while (k <= seg) {
System.out.println("Hor: " + j + " min: " + j2 + " seg: "+ k);
k++;
}
j2++;
}
j++;
}
}
}
package Empresa;
import javax.swing.JOptionPane;
public class Empresa {
public static void main(String[] args) {
{
String nombre1, sexo1;
char sexo, nomb;
int contador = 0;// contador para mujeres
int contador1 = 0;// contador para hombres
int contador2 = 0;// contador para nombres
for (int i = 0; i <= 2; i++) {
nombre1 = JOptionPane.showInputDialog(null,
"Ingrese su nombre: ");
nomb = nombre1.charAt(0);
nomb = Character.toUpperCase(nomb);
int edad1 = Integer.parseInt(JOptionPane.showInputDialog("edad"));
sexo1 = JOptionPane.showInputDialog(null,
"Ingrese el sexo M(Mujer) H(Hombre): ");
sexo = sexo1.charAt(0);
sexo = Character.toUpperCase(sexo);
if ((sexo == 'M') || (sexo == 'H')) {
if (sexo == 'M') {
contador = contador + 1;
} else {
contador1 = contador1 + 1;
}
} else {
JOptionPane.showMessageDialog(null,
"Lo que ingreso de sexo es incorrecto solo puede ser M o H");
}
if (nomb == 'A') {
contador2 = contador2 + 1;
}
}
JOptionPane
.showMessageDialog(
null,
"Este es el numero de mujeres que se presentaron:"
+ contador
+ " \n Este es el numero de hombres que se presentaron:"
+ contador1
+ " \n Este es el numero de persona que su nombre comienza con la letra A: "
+ contador2);
}
}
}
package Empresa;
import javax.swing.JOptionPane;
public class Shwich {
public static void main(String[] args) {
int s = 0;
try {
int a = Integer.parseInt(JOptionPane.showInputDialog(""));
int x = a + s;
// ahora x vale el numero que metiste
switch (x) {
case 0: {
System.out.println("esta es la opcion 0");
break;
}
case 1: {
System.out.println("esta es la opcion 1");
break;
}
default: {
System.out
.println("No se introdujo un numero dentro de las opciones");
break;
}
}
} catch (Exception err) {
System.out.println("Error, no introduciste un numero");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment