-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRead.java
94 lines (87 loc) · 1.96 KB
/
Read.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import java.util.Scanner;
class Read
{
// close after using on main with Read.reader.close
Scanner reader = new Scanner(System.in);
// read float or int method
public double ReadDouble()
{
double dNumber;
while(true)
{
try
{
dNumber = reader.nextDouble();
reader.nextLine();
break;
}
catch(Exception err)
{
System.out.print("ERROR, Intente de Nuevo: ");
reader.next();
continue;
}
}
return dNumber;
}
// read float or int method
public float ReadFloat()
{
float fNumber;
while(true)
{
try
{
fNumber = reader.nextFloat();
reader.nextLine();
break;
}
catch(Exception err)
{
System.out.print("ERROR, Intente de Nuevo: ");
reader.next();
continue;
}
}
return fNumber;
}
public int ReadInt()
{
int iNumber;
while(true)
{
try
{
iNumber = reader.nextInt();
reader.nextLine();
break;
}
catch(Exception err)
{
System.out.print("ERROR, Intente de Nuevo:");
reader.next();
continue;
}
}
return iNumber;
}
public String ReadStr()
{
String xtring;
while(true)
{
try
{
xtring = reader.nextLine();
break;
}
catch(Exception err)
{
System.out.print("ERROR, Intente de Nuevo: ");
reader.next();
continue;
}
}
return xtring;
}
}