Arnold59
Messages postés27Date d'inscriptionlundi 8 mars 2004StatutMembreDernière intervention15 avril 2019
-
30 nov. 2005 à 16:07
Arnold59
Messages postés27Date d'inscriptionlundi 8 mars 2004StatutMembreDernière intervention15 avril 2019
-
30 nov. 2005 à 17:11
Bonjour,
********************************************************
* Programme : EntreeClavier.java
* Version java : Jdk 1.3 - Jdk 1.5_5 *
* Systeme d'exploitation: Windows 98SE, XP Pro, Linux *
********************************************************/
import java.io.*;
public class EntreeClavier{
public static int readInt(){
boolean flag = false;
int i = -1;
while(!flag){
String s = "";
try{
char c;
for(c = (char)System.in.read(); c != '\n' && c != '\r'; c = (char)System.in.read())
s = s + c;
if(c == '\r')
c = (char)System.in.read();
i = Integer.parseInt(s);
flag = true;
}
catch(IOException ioexception){
System.out.println("Erreur");
}
catch(NumberFormatException numberformatexception){
System.out.println("Erreur enter un nombre");
}
}
return i;
}
public static int readInt(String s){
System.out.print(s);
return readInt();
}
public static float readFloat(){
boolean flag = false;
float f = 0.0F;
while(!flag){
String s = "";
try{
char c;
for(c = (char)System.in.read(); c != '\n' && c != '\r'; c = (char)System.in.read())
s = s + c;
if(c == '\r')
c = (char)System.in.read();
f = Float.parseFloat(s);
flag = true;
}
catch(IOException ioexception){
System.out.println("Erreur");
}
catch(NumberFormatException numberformatexception){
System.out.println("Erreur entez un nombre");
}
}
return f;
}
public static float readFloat(String s){
System.out.print(s);
return readFloat();
}
public static double readDouble(){
boolean flag = false;
double d = 0.0D;
while(!flag){
String s = "";
try{
char c;
for(c = (char)System.in.read(); c != '\n' && c != '\r'; c = (char)System.in.read())
s = s + c;
if(c == '\r')
c = (char)System.in.read();
d = Float.parseFloat(s);
flag = true;
}
catch(IOException ioexception){
System.out.println("Erreur");
}
catch(NumberFormatException numberformatexception){
System.out.println("Erreur entez un nombre");
}
}
return d;
}
public static double readDouble(String s){
System.out.print(s);
return readDouble();
}
public static char readChar(String s){
System.out.print(s);
return readChar();
}
public static String readString(){
String s = "";
try{
char c;
for(c = (char)System.in.read(); c != '\n' && c != '\r'; c = (char)System.in.read())
s = s + c;