Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Rdf
  5. {
  6. public static void main(String[] args)
  7. {
  8.  
  9. int number1;
  10.  
  11. number1 = getNumb();
  12.  
  13. sumOfNumbers(number1);
  14. }
  15. public static int getNumb()
  16. {
  17. int input;
  18. System.out.println("Prosze wprowadzic liczbe");
  19. Scanner scanner = new Scanner(System.in);
  20. input = scanner.nextInt();
  21. if (input <1)
  22. {
  23. System.out.println("Wprowadzona liczba jest nie poprawna, proszę jeszcze raz wpisac liczbe");
  24. getNumb();
  25. }
  26. return input;
  27. }
  28.  
  29. public static void sumOfNumbers(int input)
  30. {
  31. for(int i =1; i<input; i++)
  32. {
  33.  
  34. System.out.print(i + " ");
  35.  
  36. }
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement