0% found this document useful (0 votes)
54 views7 pages

Ejercicio #1

The document contains 3 programming exercises and 2 exam problems completed by a student named Sanchez Laura Naldo Fernando. The first exercise calculates the factorial of a user-input number. The second determines if a number is even or odd and prints its predecessors. The third prints a pattern of I's and O's based on a user-input number. The exam problems include: 1) calculating factorials and their sums for even and odd numbers, and 2) calculating the average of 5 user-input grades and determining if the student passes or needs a complementary exam.

Uploaded by

wendy tereshkova
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views7 pages

Ejercicio #1

The document contains 3 programming exercises and 2 exam problems completed by a student named Sanchez Laura Naldo Fernando. The first exercise calculates the factorial of a user-input number. The second determines if a number is even or odd and prints its predecessors. The third prints a pattern of I's and O's based on a user-input number. The exam problems include: 1) calculating factorials and their sums for even and odd numbers, and 2) calculating the average of 5 user-input grades and determining if the student passes or needs a complementary exam.

Uploaded by

wendy tereshkova
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

EJERCICIOS DE PROGRAMACIÓN

Estudiante: Sanchez Laura Naldo Fernando

Ejercicio N° 1

package tarea.i;

import java.util.Scanner;

public class TareaI {

public static void main(String[] args) {

int nu,m,s=1;

Scanner num=new Scanner(System.in);

System.out.println("Ingrese numero: ");

nu=num.nextInt();

for(m=1;m<=nu;m++){

s=s*m;

System.out.println("El factorial de "+nu+" es: "+s);

Ejercicio N° 2

package tarea.ii;

import java.util.Scanner;

public class TareaII {

public static void main(String[] args) {

int x,y;

Scanner num=new Scanner(System.in);

System.out.println("Ingrese un numero: ");

x=num.nextInt();

if(x%2==0){

System.out.println("El numero es PAR ");


System.out.println("Sus predesesores son: ");

for (y=1;y<x;y++)

System.out.println(y);

else {

System.out.println("El numero es IMPAR ");

System.out.println("Sus predesesores son: ");

for (y=1;y<x;y++)

System.out.println(y);}

Ejercicio N° 3

package tarea.iii;

import java.io.*;

public class TareaIII {

public static void main(String[] args)throws IOException {

int num,x,y,z,r;

BufferedReader lectura=new BufferedReader(new InputStreamReader(System.in));

System.out.println("Ingrese un Numero: ");

num=Integer.parseInt(lectura.readLine());

System.out.println(".............................");

r=1;

for (x=0;x<num;x=x+2)

for(y=1;y<r+1;y++)

System.out.print("I");

System.out.println();

if (r<num)

for(z=0;z<r+1;z++)
System.out.print("O");

System.out.println();

r=r+2;

EXAMENNNNNNNNNNNNNN
1)

package examen.i;

import java.util.Scanner;

public class ExamenI {

public static void main(String[] args) {

int nu,m,x,s,y,z;

s=1;

y=0;

z=0;

Scanner num=new Scanner(System.in);

System.out.println("Ingrese numero: ");

x=num.nextInt();

for(m=1;m<=x;m++){

s=s*m;

System.out.println(m+"! = "+s);

if(m%2==0){

z=z+s;

}
else {

y=y+s;

System.out.println("=====================================");

System.out.println("La factorial de "+(m-1)+" es: "+s);

System.out.println("La suma de los numeros impares es "+y);

2)

package examen.i;

import java.io.*;

import java.util.Scanner;

public class ExamenI {

public static void main(String[] args) {

Scanner lectura=new Scanner(System.in);

float n1,n2,n3,n4,n5,prom;

System.out.print("Ingrese Nota 1: ");

do

{ n1=lectura.nextFloat();

if(n1<0){

System.out.println("Error ");

System.out.println("Vuelva a Ingresar ");

}
if(n1>20){

System.out.println("Error ");

System.out.println("Vuelva a Ingresar ");

}while(n1<1);

System.out.print("Ingrese Nota 2: ");

do

{ n2=lectura.nextFloat();

if(n2<0){

System.out.println("Error ");

System.out.println("Vuelva a Ingresar ");

if(n2>20){

System.out.println("Error ");

System.out.println("Vuelva a Ingresar ");

}while(n2<1);

System.out.print("Ingrese Nota 3: ");

do

{ n3=lectura.nextFloat();

if(n3<0){

System.out.println("Error ");

System.out.println("Vuelva a Ingresar ");

if(n3>20){

System.out.println("Error ");

System.out.println("Vuelva a Ingresar ");

}while(n3<1);

System.out.print("Ingrese Nota 4: ");


do

{ n4=lectura.nextFloat();

if(n4<0){

System.out.println("Error ");

System.out.println("Vuelva a Ingresar ");

if(n4>20){

System.out.println("Error ");

System.out.println("Vuelva a Ingresar ");

}while(n4<1);

System.out.print("Ingrese Nota 5: ");

do

{ n5=lectura.nextFloat();

if(n5<0){

System.out.println("Error ");

System.out.println("Vuelva a Ingresar ");

if(n5>20){

System.out.println("Error ");

System.out.println("Nota es invalida vuelva a Ingresar ");

}while(n5<1);

prom=((n1+n2+n3+n4+n5)/5);

System.out.println("==========================================");

System.out.println("El promedio es: "+prom);

if(prom<7){

System.out.println("No complementario ");

if(prom>7 && prom<10.5){

System.out.println("Entra al complementario ");


}

if(prom>10.5){

System.out.println("Aprobado ");

You might also like