SHARE
TWEET

Untitled

a guest Jan 17th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. System.out.print("Enter How Many Inputs: ");
  2. int num1 = Integer.parseInt(in.readLine());
  3. for (int x = 1; x<=num1;x++){
  4.     for (int i = 0 ; i<num1;){
  5.         System.out.print("Enter Value #" + x++ +":");
  6.         int ctr1 =Integer.parseInt(in.readLine());
  7.         i++;
  8.     }
  9. }
  10.    
  11. Enter How Many Inputs: 5
  12. Enter Value #1:22
  13. Enter Value #2:1
  14. Enter Value #3:3
  15. Enter Value #4:5
  16. Enter Value #5:6
  17.    
  18. System.out.print("Enter How Many Inputs: ");
  19. int num1 = Integer.parseInt(in.readLine());
  20. int arr[] = new int[num1];
  21.  
  22. for (int i = 0; i<num1; i++)
  23. {
  24.     System.out.print("Enter Value #" + (i + 1) + ":");
  25.     arr[i] =Integer.parseInt(in.readLine());
  26. }
  27.    
  28. for(int i = 0; i < arr.length; i++)
  29.     System.out.println(arr[i]);
  30.    
  31. import java.util.Arrays;
  32.    
  33. Arrays.sort(arr);
  34.    
  35. Scanner scan = new Scanner(System.in);
  36.         System.out.println("enter num of values: ");
  37.         int [] arr = new int[scan.nextInt()];
  38.         for(int i=0;i<arr.length; i++) {
  39.             scan = new Scanner(System.in);
  40.             System.out.println("please enter a value: ");
  41.             while(scan.hasNextInt()){
  42.             int x = scan.nextInt()
  43.                     ;
  44.             arr[i]= x;
  45.             break;
  46.             }
  47.  
  48.         }
  49.         for(int i:arr){
  50.             System.out.print(i);
  51.         }
  52.    
  53. Scanner in = new Scanner(System.in);
  54. System.out.print("Enter How Many Inputs: ");
  55. int num1 = in.nextInt();
  56. int[] a = new int[num1];
  57. for (int i = 0 ; i < num1 ; i++) {
  58.     System.out.print("Enter Value #" + (i + 1) +": ");
  59.     a[i] = in.nextInt();
  60. }
  61. System.out.println(Arrays.toString(a));
  62. in.close();
  63.    
  64. Scanner in = new Scanner(System.in);
  65. System.out.print("Enter How Many Inputs: ");
  66. int num1 = in.nextInt();
  67. String s = "";
  68. for (int i = 0 ; i < num1 ; i++) {
  69.     System.out.print("Enter Value #" + (i + 1) +": ");
  70.     s += ", " + in.nextInt();
  71. }
  72. System.out.println(s.substring(2));  // we need to cut off the initial ", "
  73. in.close();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top