Minimum - Maximum - Quatre variables JAVA

439 mots 2 pages
public class ED04_05 { public static void main(String [] args){ System.out.println("Début - Exécution ED04_05\n"); System.out.println("Minimum - Maximum - Quatre variables"); System.out.println("-------------------------------------"); System.out.println(); int n1,n2,n3,n4,max,min; System.out.print("Saisir n1 : "); n1=Lire.entierInt(); System.out.print("Saisir n2 : "); n2=Lire.entierInt(); System.out.print("Saisir n3 : "); n3=Lire.entierInt(); System.out.print("Saisir n4 : "); n4=Lire.entierInt(); max=Math.max(Math.max(n1,n2),Math.max(n3,n4)); min=Math.min(Math.min(n1,n2),Math.min(n3,n4)); System.out.println(); System.out.println("La plus petite valeur est : "+min); System.out.println("La plus grande valeur est :"+max); System.out.println(); System.out.println("Fin - Exécution ED04_05"); }
}

lire.java

import java.io.IOException;

public class Lire
{
// Cette fonction permet de saisir au clavier une variable de type String public static String chaine() { String tmp = ""; char C='\0'; try { while ((C=(char) System.in.read()) !='\n') { if (C != '\r') tmp = tmp+C; } } catch (IOException e) { System.out.println("Erreur de frappe"); System.exit(0); } return tmp; }

// Cette fonction permet de saisir au clavier une variable entière de type byte public static byte entierByte() { byte x=0; try { x = Byte.parseByte(chaine()); } catch (NumberFormatException e) { System.out.println("Format numérique incorrect"); System.exit(0); } return x ; }

// Cette fonction permet de saisir au clavier une variable entière de type Short public static short entierShort() { short x=0; try { x=Short.parseShort(chaine()); } catch (NumberFormatException e) { System.out.println("Format numérique incorrect");

en relation

  • Algorythme et listes en pyp
    1767 mots | 8 pages
  • Er bipède final
    4324 mots | 18 pages
  • Cours Unix
    8503 mots | 35 pages
  • Ejb-enchainement d'un projet de j2ee
    1023 mots | 5 pages
  • Wow pfeg rien à voir
    679 mots | 3 pages
  • Darjelinng
    5442 mots | 22 pages
  • Transmissions réseaux
    1300 mots | 6 pages
  • Audit chupa chups
    13902 mots | 56 pages
  • Rapport de stage bac pro eleec
    267 mots | 2 pages
  • specifications breves
    403 mots | 2 pages
  • La démarche de soins
    5298 mots | 22 pages
  • physique
    938 mots | 4 pages
  • Documentations
    1932 mots | 8 pages
  • Ezs1450
    6802 mots | 28 pages
  • Le loup
    358 mots | 2 pages