0% found this document useful (0 votes)
6 views3 pages

Ejercicios Programacion

The document contains three Java exercises focused on basic programming concepts. Exercise 1 calculates the average of student grades and categorizes the result, Exercise 2 generates a multiplication table for a given number using different loop structures, and Exercise 3 counts the number of students with grades above and below a specified threshold. Each exercise utilizes the Scanner class for user input and demonstrates fundamental control flow in Java.
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)
6 views3 pages

Ejercicios Programacion

The document contains three Java exercises focused on basic programming concepts. Exercise 1 calculates the average of student grades and categorizes the result, Exercise 2 generates a multiplication table for a given number using different loop structures, and Exercise 3 counts the number of students with grades above and below a specified threshold. Each exercise utilizes the Scanner class for user input and demonstrates fundamental control flow in Java.
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/ 3

EJERCICIO 1:

import java.util.Scanner;

public class Ejercicio1PromedioNotas {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Ingrese el numero de notas: ");

int N = scanner.nextInt();

int i = 0;

double suma = 0;

while (i < N) {

System.out.print("Ingrese la nota " + (i+1) + ": ");

double nota = scanner.nextDouble();

suma += nota;

i++;

double promedio = suma / N;

System.out.println("Promedio: " + promedio);

System.out.println("Condicion: " + obtenerCondicion(promedio));

scanner.close();

private static String obtenerCondicion(double promedio) {

if (promedio >= 0 && promedio <= 11) return "Desaprobado";

if (promedio > 11 && promedio <= 15) return "Regular";

if (promedio > 15 && promedio <= 18) return "Bueno";

if (promedio > 18 && promedio <= 20) return "Excelente";

return "Fuera de rango";

}
EJERCICIO 2:

import java.util.Scanner;

public class Ejercicio2TablaMultiplicar {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Ingrese un numero para la tabla de multiplicar: ");

int num = scanner.nextInt();

// Usando while

System.out.println("\nUsando while:");

int i = 1;

while (i <= 10) {

System.out.println(num + " x " + i + " = " + (num * i));

i++;

// Usando do-while

System.out.println("\nUsando do-while:");

i = 1;

do {

System.out.println(num + " x " + i + " = " + (num * i));

i++;

} while (i <= 10);

// Usando for

System.out.println("\nUsando for:");

for (i = 1; i <= 10; i++) {

System.out.println(num + " x " + i + " = " + (num * i));

scanner.close();

}
EJERCICIO 3:

import java.util.Scanner;

public class Ejercicio3ConteoNotas {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Ingrese el numero de alumnos: ");

int N = scanner.nextInt();

int mayoresOIguales = 0;

int menores = 0;

for (int i = 0; i < N; i++) {

System.out.print("Ingrese la nota del alumno " + (i+1) + ": ");

double nota = scanner.nextDouble();

if (nota >= 11.5) {

mayoresOIguales++;

} else {

menores++;

System.out.println("Alumnos con notas mayores o iguales a 11.5: " + mayoresOIguales);

System.out.println("Alumnos con notas menores a 11.5: " + menores);

scanner.close();

You might also like