-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLectura.java
More file actions
171 lines (165 loc) · 4.4 KB
/
Copy pathLectura.java
File metadata and controls
171 lines (165 loc) · 4.4 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import java.io.*;
class Lectura{
public static byte readByte(String letrero)
{
System.out.println(letrero);
DataInputStream d = new DataInputStream(System.in);
String g;
byte x = 0;
byte sw = 0;
byte f = 0;
do {
try
{
g=d.readLine();
f = Byte.parseByte(g);
sw = 0;
}
catch(NumberFormatException e)
{
System.out.println("No es un dato válido");
sw=1;
}
catch (IOException e){g="0";}
}while (sw ==1);
return f;
}
public static int readInt(String letrero)
{
System.out.println(letrero);
DataInputStream d = new DataInputStream(System.in);
String g;
int x = 0;
int sw = 0;
int f = 0;
do {
try
{
g=d.readLine();
f = Integer.parseInt(g);
sw = 0;
}
catch(NumberFormatException e)
{
System.out.println("No es un dato válido");
sw=1;
}
catch (IOException e){g="0";}
}while (sw ==1);
return f;
}
public static short readShort(String letrero)
{
System.out.println(letrero);
DataInputStream d = new DataInputStream(System.in);
String g;
short x = 0;
short sw = 0;
short f = 0;
do {
try
{
g=d.readLine();
f = Short.parseShort(g);
sw = 0;
}
catch(NumberFormatException e)
{
System.out.println("No es un dato válido");
sw=1;
}
catch (IOException e){g="0";}
}while (sw ==1);
return f; }
public static long readLong(String letrero)
{
System.out.println(letrero);
DataInputStream d = new DataInputStream(System.in);
String g;
long x = 0;
long sw = 0;
long f = 0;
do {
try
{
g=d.readLine();
f = Long.parseLong(g);
sw = 0;
}
catch(NumberFormatException e)
{
System.out.println("No es un dato válido");
sw=1;
}
catch (IOException e){g="0";}
}while (sw ==1);
return f;
}
public static float readFloat(String letrero)
{
System.out.println(letrero);
DataInputStream d = new DataInputStream(System.in);
String g;
float x = 0;
float sw = 0;
float f = 0;
do {
try
{
g=d.readLine();
f = Float.parseFloat(g);
sw = 0;
}
catch(NumberFormatException e)
{
System.out.println("No es un dato válido");
sw=1;
}
catch (IOException e){g="0";}
}while (sw ==1);
return f; }
public static double readDouble(String letrero)
{
System.out.println(letrero);
DataInputStream d = new DataInputStream(System.in);
String g;
double x = 0;
double sw = 0;
double f = 0;
do {
try
{
g=d.readLine();
f = Double.parseDouble(g);
sw = 0;
}
catch(NumberFormatException e)
{
System.out.println("No es un dato válido");
sw=1;
}
catch (IOException e){g="0";}
}while (sw ==1);
return f; }
public static char readChar(String letrero)
{
System.out.println(letrero);
DataInputStream u = new DataInputStream(System.in);
String v;
try
{v=u.readLine();}
catch (IOException e){v="0";}
char w = v.charAt(0);
return w;
}
public static String readString(String letrero)
{
System.out.println(letrero);
DataInputStream x = new DataInputStream(System.in);
String y;
try
{y=x.readLine();}
catch (IOException e){y="0";}
return y;
}
}