Advertisement
Vladkoheca

one or two.java

Nov 12th, 2024 (edited)
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | Source Code | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.  
  8.         System.out.println("Pick 1 or 2 ");
  9.         int one_or_two = Integer.parseInt(sc.nextLine());
  10.        
  11.         if (one_or_two ==1){
  12.             int[] massive1 = new int [3];
  13.             for (int i = 0; i< massive1.length; i++) {
  14.                 int x = Integer.parseInt(sc.nextLine());
  15.                 massive1[i] = x;
  16.             }
  17.             System.out.println(Arrays.toString(massive1));
  18.            
  19.         }   else if (one_or_two == 2){
  20.             String[] massive2 = new String [3];
  21.             for (int i = 0; i< massive2.length; i++) {
  22.                 String y = sc.nextLine();
  23.                 massive2[i] = y;
  24.             }
  25.             System.out.println(Arrays.toString(massive2));
  26.            
  27.         }   else {
  28.             System.out.println("Type one(1) or two(2)");
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement