Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. public static double broj(){
  2.         Scanner sc = new Scanner(System.in);
  3.         Boolean provjera=false;
  4.         double broj = 0;
  5.         while(!provjera){
  6.             System.out.print("Please provide width:");
  7.             String ulaz = sc.next();
  8.             ulaz.trim();
  9. /*i sad ovaj zadatak traži da se nađe ako je prazan string da se kao kaže da nemože primit praznine a meni ovo kad lupim enter
  10. u system.in ili par spaceva nikad nije true tj cak mi sc.next to ni ne učita*/
  11.             if(ulaz.isEmpty())
  12.                 System.err.println("The input must not be blank.");
  13.            
  14.             else{
  15.                 broj = Double.parseDouble(ulaz);
  16.                 if (broj <=0)
  17.                     System.err.println("The width must not be negative.");
  18.                 else provjera=true;
  19.             }
  20.         }
  21.         sc.close();
  22.         return broj;
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement