Prob Re Mario
Prob Re Mario
Carrera:
Ingeniera Industrial.
Asignatura:
Tema:
Problemario de unidades 3,4,5 y 6
Nombre:
Rolando González García.
Docente:
I.S.C. Samuel Efrén Viñas Álvarez.
Semestre:
Enero-junio 2018
1.- import java.util.Scanner;
public class Ejercio {
public static void main(String[] args) {
int op=0;
Scanner entrada = new Scanner(System.in);
do{
System.out.println("Menu de Opciones");
System.out.println("**3. SALIR**");
op=entrada.nextInt();
switch(op)
{
case 1:
int n;
int num;
int pares=0;
int imp=0;
System.out.println("dame el numero de datos a evaluar");
n = entrada.nextInt();
for(int i=1;i<=n;i++)
{
System.out.println("dame los numeros: ");
num = entrada.nextInt();
if(num % 2 ==0)
{
pares = pares+1;
}
else
{
imp = imp+1;
}
}
System.out.println("EL TOTAL DE NUMEROS PARES ES: "+pares);
System.out.println("EL TOTAL DE NUMEROS IMPARES ES: "+imp);
break;
case 2:
int cont,res,num1,n1,neg=0,pos=0,cero=0;
for (cont=1;cont<=n1;cont++)
{
System.out.println(cont);
System.out.println("Ingrese los numeros");
num1=entrada.nextInt();
if (num1<0)
{
neg++;
}
if (num1>0)
{
pos++;
}
if(num1==0)
{
cero++;
}
}
System.out.println("EL TOTAL DE LOS NUMEROS NEGATIVOS SON:"
+neg);
System.out.println("EL TOTAL DE LOS NUMEROS POSITIVOS SON: "+pos);
System.out.println("EL TOTAL DE NUMEROS CEROS ES: "+cero);
break;
case 3:
case 4:
System.exit(0);
break;
default:
System.out.println("seleccione una opcion");
break;
}
} while(op !=4);
}
}
2.- import java.util.Scanner;
public class Lector {
public static void main(String[] args) {
int op=0;
int vec[] ;
vec= new int[5];
Scanner entrada=new Scanner(System.in);
do{
System.out.println("Menu de la operacion");
}
break;
case 2:
for(int i=0; i<vec.length;i++) {
System.out.println(vec[i]);
}
break;
case 3:
break;
}
if (tipos==1){
monto = ((pago*kilos)+(kilos*0.20));
}
else{
monto = ((pago*kilos)+(kilos*0.30));
}
if (tamaño==1){
monto2 = ((pago*kilos)-(kilos*0.30));
}
else{
monto2 = (pago*kilos)-(kilos*0.50);
}
if (traje>=2500){
desc = (traje*0.15);
total = (traje-desc);
}
else{
desc = (traje*0.08);
total = (traje-desc);
}
}
}
if (tipos==1){
monto = ((pago*kilos)+(kilos*0.20));
}
else{
monto = ((pago*kilos)+(kilos*0.30));
}
if (tamaño==1){
monto2 = ((pago*kilos)-(kilos*0.30));
}
else{
monto2 = (pago*kilos)-(kilos*0.50);
}
do{
System.out.println("Menu de Opciones");
System.out.println("4. Salir");
switch(op){
case 1:
int a=0, b=0, c=0;
System.out.println("Ingresa un numero");
a = entrada.nextInt();
System.out.println("Ingresa un numero");
b = entrada.nextInt();
c = a + b;
System.out.println("la suma es"+c);
break;
case 2:
int x=0, y=0, z=0;
System.out.println("Ingresa un numero");
x = entrada.nextInt();
System.out.println("Ingresa un numero");
y = entrada.nextInt();
z = x - y;
System.out.println("La resta es"+z);
break;
case 3:
int num=0,resul;
System.out.println("Ingresa un numero");
num = entrada.nextInt();
for(int i=1;i<=10;i++){
resul= num * i;
System.out.println(num+"*"+i+"="+resul);
}
break;
case 4:
System.exit(0);
}
} while(op !=4);
}
}
for (cont=1;cont<=n;cont++)
{
System.out.println(cont);
System.out.println("Ingrese los numeros");
num=sc.nextInt();
res=num % 2;
if(res==0)
{
acum=acum+1;
}
else
{
acum1=acum1+1;
}
if (num<0)
{
neg++;
}
if (num>0)
{
pos++;
}
if(num==0)
{
cero++;
}
do{
System.out.println("***Menu de opcioes***");
System.out.println("1.- Ingresar numeros");
System.out.println("2.- Mostrar");
System.out.println("3.-Salir");
System.out.println("Elige una opcion: ");
op = entrada.nextInt();
switch(op){
case 1:
for (int i=0;i<vec1.length;i++){
System.out.println("ingrese un numero: ");
num= entrada.nextInt();
if(num>0){
vec1[i]=num;
}else{
vec2[i]=num;
}
}
break;
case 2:
case 3:
System.exit(0);
break;
}
}while(op !=5);
if (tipos==1){
monto = ((pago*kilos)+(kilos*0.20));
}
else{
monto = ((pago*kilos)+(kilos*0.30));
}
if (tamaño==1){
monto2 = ((pago*kilos)-(kilos*0.30));
}
else{
monto2 = (pago*kilos)-(kilos*0.50);
}
if (tipos==1){
monto = ((pago*kilos)+(kilos*0.20));
}
else{
monto = ((pago*kilos)+(kilos*0.30));
}
if (tamaño==1){
monto2 = ((pago*kilos)-(kilos*0.30));
}
else{
monto2 = (pago*kilos)-(kilos*0.50);
}
11.-import java.util.Scanner;
public class Matrices {
int mat1[][], mat2[][], mat3[][];
{
System.out.println("Escribe un numero");
mat1[i][j]= entrada.nextInt();
}
}
for (int i=0;i<mat2.length;i++)
{
for (int j=0;j<mat1.length;j++)
{
System.out.println("Escribe un numero");
mat2[i][j]= entrada.nextInt();
}
}
}
public void SUMA(){
Scanner entrada = new Scanner(System.in);
for (int i=0;i<mat1.length;i++)
{
for (int j=0;j<mat1.length;j++)
{
mat3[i][j]=mat1[i][j]+mat2[i][j];
System.out.print(mat3[i][j]+"\t");
}
System.out.println();
}
}
public void RESTA(){
}
System.out.println();
}
}
public void MULTIPLICACION(){
}
System.out.println();
}
}
switch (op){
case 1:
pedirnumeros();
break;
case 2:
SUMA();
break;
case 3:
RESTA();
break;
case 4:
MULTIPLICACION();
break;
case 5:
System.exit(0);
}
}while(op !=5);
}
switch (op){
case 1:
pedirnumeros();
break;
case 2:
SumarNumeros();
break;
case 3:
RestarNumeros();
break;
case 4:
MultiplicarNumeros();
break;
case 5:
DividirNumeros();
break;
case 6:
Potencia();
break;
case 7:
Raiz();
break;
case 8:
System.exit(0);
}
}while(op !=8);
}
do{
System.out.println("**Menu de opciones**");
System.out.println("1.-Pedir numeros");
System.out.println("2.-Suma");
System.out.println("3.-Resta");
System.out.println("4.-Multiplicación");
System.out.println("5.-Salir");
System.out.println("Elige una opcion");
op= entrada.nextInt();
switch(op){
case 1:
for (int i=0;i<mat1.length;i++)
{
for (int j=0;j<mat1.length;j++)
{
System.out.println("Escribe un numero");
mat1[i][j]= entrada.nextInt();
}
}
for (int i=0;i<mat2.length;i++)
{
for (int j=0;j<mat1.length;j++)
{
System.out.println("Escribe un numero");
mat2[i][j]= entrada.nextInt();
}
}
break;
case 2:
for (int i=0;i<mat1.length;i++)
{
for (int j=0;j<mat1.length;j++)
{
mat3[i][j]=mat1[i][j]+mat2[i][j];
System.out.print(mat3[i][j]+"\t");
}
System.out.println();
}
break;
case 3:
for (int i=0;i<mat1.length;i++)
{
for (int j=0;j<mat1.length;j++)
{
mat3[i][j]=mat1[i][j]-mat2[i][j];
System.out.print(mat3[i][j]+"\t");
}
System.out.println();
}
break;
case 4:
for (int i=0;i<mat1.length;i++)
{
for (int j=0;j<mat1.length;j++)
{
mat3[i][j]=mat1[i][0]*mat2[0][j]+mat1[i][1]*mat2[1][j]+mat1[i][2]*mat2[2][j];
System.out.print(mat3[i][j]+"\t");
}
System.out.println();
}
break;
case 5:
System.exit(0);
break;
}while(op !=5);
}
}