Está en la página 1de 6

Ejercicios simples

1.- Se ingresan tres notas de un alumno, si el promedio es mayor o igual a siete mostrar un
mensaje "Promocionado"

import java.util.Scanner;

public class Main {

public static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {

int not1,not2,not3;

System.out.print("Ingrese primer nota:");

not1=sc.nextInt();

System.out.print("Ingrese segunda nota:");

not2=sc.nextInt();

System.out.print("Ingrese tercer nota:");

not3=sc.nextInt();

int promedio;

promedio=(not1 + not2 + not3) / 3;

if (promedio>=7)

System.out.print("Promediado");

2.-import java.util.Scanner;

public class Main {

public static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {

float sueldo;

System.out.print("Ingrese el sueldo:");

sueldo=sc.nextFloat();

if (sueldo>3000) {

System.out.println("Esta persona debe abonar impuestos");

}
Double

1.- import java.util.Scanner;

public class Main {

public static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {

String dia;

double monto_compra,descuento, total1, total2;

System.out.print("Ingrese el monto de compra: ");

monto_compra=sc.nextInt();

System.out.print("Ingrese el dia de semana: ");

dia=sc.next();

descuento= 0.15*monto_compra;

total1 = monto_compra - descuento;

total2=monto_compra;

if(dia.equals("martes")||dia.equals("jueves")){

System.out.println("El Descuento es: "+ descuento);

System.out.println("El total es: " + total1);

else

System.out.println("El total es: " + total2);

}
2. Tiendas Don Pepe desea un programa para ingresar por teclado el monto de compra y el día de
la semana; si el día es martes o jueves, se realizará un descuento del 15% por la compra. Visualizar
el descuento y el total a pagar por la compra.

import java.util.Scanner;

public class Main {

public static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {

double temperatura, tiempo;

System.out.println("temperatura");

System.out.println("tiempo");

temperatura = sc.nextDouble();

tiempo = sc.nextDouble();

if (temperatura>25){

System.out.println("ir a la playa" );

}if(temperatura<=25){

System.out.println("esperar el buen tiempo");

}if(tiempo>25){

System.out.println("no ir a la playa");

}if(tiempo<=25){

System.out.println("ir a la playa");

}
Anidada

Se ingresan tres valores por teclado que representan las notas de un alumno, se obtiene el
promedio sumando los tres valores y dividiendo por 3 dicho resultado (Tener en cuenta que si el
resultado es un valor real solo se almacena la parte entera).

Primeramente preguntamos si el promedio es superior o igual a 7, en caso afirmativo va por la


rama del verdadero de la estructura condicional mostramos un mensaje que indica
"Promocionado" (con comillas indicamos un texto que debe imprimirse en pantalla).

import java.util.Scanner;

public class Main {

public static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {

int nota1,nota2,nota3;

System.out.print("Ingrese primer nota:");

nota1=sc.nextInt();

System.out.print("Ingrese segunda nota:");

nota2=sc.nextInt();

System.out.print("Ingrese tercer nota:");

nota3=sc.nextInt();

int promedio=(nota1 + nota2 + nota3) / 3;

if (promedio>=7) {

System.out.print("Aprobado");

} else {

} if (promedio>=4) {

System.out.print("Regular");

} else {

System.out.print("Reprobado");

}
2. Confeccionar un programa que permita cargar un número entero positivo de hasta tres cifras y
muestre un mensaje indicando si tiene 1, 2, o 3 cifras. Mostrar un mensaje de error si el número
de cifras es mayor.

public class Main {

public static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {

int num;

System.out.print("Ingrese un valor:");

num=sc.nextInt();

if (num==0) {

System.out.print("Se ingresó el cero");

} else {

}if (num>0) {

System.out.print("Se ingresó un valor positivo");

} else {

System.out.print("Se ingresó un valor negativo");

Múltiples

Diseñe un programa que lea la temperatura en centígrados del día e imprima el tipo de clima de
acuerdo a la siguiente tabla.

import java.util.Scanner;

public class Main {

public static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {

double tp;

String clima;
System.out.print("Ingrese la temperatura: ");

tp = sc.nextDouble();

if(tp<=10){

System.out.println("La temperatura es FRIO");

else if(tp>10 && tp<=20){

System.out.println("La temperatura es NUBLADO");

else if(tp>20 && tp<=30){

System.out.println("La temperatura es CALUROSO");

else if(tp>30){

System.out.println("La temperatura es TROPICAL");

2.

También podría gustarte