Felanpro

uppgift87

Nov 19th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package skola;
  7. import java.util.Scanner;
  8. /**
  9. *
  10. * @author Felix 1
  11. */
  12. public class Uppgift87 {
  13.  
  14. /**
  15. * @param args the command line arguments
  16. */
  17. public static void main(String[] args) {
  18. Scanner inmatning = new Scanner(System.in);
  19.  
  20. int[] fält = new int[10];
  21. boolean fortsätt = true;
  22. int tal = 1;
  23. int i = 0;
  24. int input;
  25. while(fortsätt)
  26. {
  27. System.out.print("Tal nr " + tal + ": ");
  28.  
  29. input = inmatning.nextInt();
  30. if(input >= 0)
  31. fält[i] = input;
  32. else
  33. break;
  34.  
  35. i++;
  36. tal++;
  37. }
  38.  
  39. for(int x = 0; fält[x] != 0; x++)
  40. {
  41. System.out.println(fält[x]);
  42. }
  43. }
  44.  
  45. }
  46.  
Add Comment
Please, Sign In to add comment