radko93

Untitled

Jan 20th, 2013
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.util.*;
  2. public class trzyliczby {
  3.     public void liczby() {
  4.        
  5.     int tab[]= new int[3];
  6.     System.out.println("Wprowadz liczbe calkowita:");
  7.         Scanner sc= new Scanner(System.in);
  8.         while(!sc.hasNextInt()) {
  9.         System.out.println("to nie jest liczba całkowita.");
  10.         System.out.println(sc.next());
  11.         System.out.print("Wprowadz ponownie: ");
  12.         }
  13.         tab[0]=sc.nextInt();
  14.         while(!sc.hasNextInt()) {
  15.             System.out.println("to nie jest liczba całkowita.");
  16.             System.out.println(sc.next());
  17.             System.out.print("Wprowadz ponownie: ");
  18.             }
  19.         tab[1]=sc.nextInt();
  20.         while(!sc.hasNextInt()) {
  21.             System.out.println("to nie jest liczba całkowita.");
  22.             System.out.println(sc.next());
  23.             System.out.print("Wprowadz ponownie: ");
  24.             }
  25.         tab[2]=sc.nextInt();
  26.         for(int i=0;i<3;i++) {
  27.             System.out.println(tab[i]);
  28.         }
  29.         String znak="<";
  30.         Arrays.sort(tab);
  31.        
  32.         System.out.println();
  33.         for(int j=0;j<3;j++) {
  34.             System.out.printf("%7d%7s",tab[j],znak);
  35.         }
  36.        
  37.    
  38.     }
  39.    
  40.     public static void main(String[] args) {
  41.         trzyliczby test= new trzyliczby();
  42.         test.liczby();
  43.  
  44.     }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment