-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ejercicio13.java
58 lines (48 loc) · 1.92 KB
/
Ejercicio13.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Ejercicio # 13
Escriba un programa que valide si una nota está entre 0 y 10, sino está entre 0 y 10
la nota se pedirá de nuevo hasta que la nota sea correcta
*/
package egg_ejercicios;
import java.util.Scanner;
/**
*
* @author WALTER GOMEZ
*/
public class Ejercicio13 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner leer = new Scanner(System.in).useDelimiter("\n");
//DecimalFormat df = new DecimalFormat("###.##");
int nota;
String dato;
dato = "";
System.out.print(" -- Digite una nota entre 0 y 10 -- \n");
nota = leer.nextInt();
while (nota < 0 || nota > 10) {
System.out.print(" -- El valor de la nota está fuera del rango, ingrese nuevamente el valor!! -- \n");
nota = leer.nextInt();
}
System.out.print(" -- La nota ingresa es :"+nota+" es Correcto!!! -- \n");
System.out.print(" Desea volver a ingresar el dato (S = si / N = no)\n");
dato = leer.next().trim();
while (dato != "") {
// System.out.print(" Desea volver a ingresar el dato (S = si / N = no)\n");
// dato = leer.next().trim();
if (dato.equalsIgnoreCase("s")) {
System.out.print(" -- Digite una nota entre 0 y 10 -- \n");
nota = leer.nextInt();
while (nota < 0 || nota > 10) {
System.out.print(" -- El valor de la nota está fuera del rango, ingrese nuevamente el valor!! -- \n");
nota = leer.nextInt();
}
System.out.print(" -- La nota ingresa es :"+nota+" es Correcto!!! -- \n");break;
} else {
System.out.print(" -- Salio del programa -- \n");
break;
}
}
}
}